<s> '''<STR_LIT>''' <EOL> from __future__ import absolute_import <EOL> import logging <EOL> import salt . utils . openstack . nova as suon <EOL> log = logging . getLogger ( __name__ ) <EOL> __func_alias__ = { <EOL> '<STR_LIT>' : '<STR_LIT:list>' <EOL> } <EOL> __virtualname__ = '<STR_LIT>' <EOL> def __virtual__ ( ) : <EOL> '''<STR_LIT>''' <EOL> if suon . check_nova ( ) : <EOL> return __virtualname__ <EOL> return ( False , '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> __opts__ = { } <EOL> def _auth ( profile = None ) : <EOL> '''<STR_LIT>''' <EOL> if profile : <EOL> credentials = __salt__ [ '<STR_LIT>' ] ( profile ) <EOL> user = credentials [ '<STR_LIT>' ] <EOL> password = credentials [ '<STR_LIT>' ] <EOL> tenant = credentials [ '<STR_LIT>' ] <EOL> auth_url = credentials [ '<STR_LIT>' ] <EOL> region_name = credentials . get ( '<STR_LIT>' , None ) <EOL> api_key = credentials . get ( '<STR_LIT>' , None ) <EOL> os_auth_system = credentials . get ( '<STR_LIT>' , None ) <EOL> else : <EOL> user = __salt__ [ '<STR_LIT>' ] ( '<STR_LIT>' ) <EOL> password = __salt__ [ '<STR_LIT>' ] ( '<STR_LIT>' ) <EOL> tenant = __salt__ [ '<STR_LIT>' ] ( '<STR_LIT>' ) <EOL> auth_url = __salt__ [ '<STR_LIT>' ] ( '<STR_LIT>' ) <EOL> region_name = __salt__ [ '<STR_LIT>' ] ( '<STR_LIT>' ) <EOL> api_key = __salt__ [ '<STR_LIT>' ] ( '<STR_LIT>' ) <EOL> os_auth_system = __salt__ [ '<STR_LIT>' ] ( '<STR_LIT>' ) <EOL> kwargs = { <EOL> '<STR_LIT:username>' : user , <EOL> '<STR_LIT:password>' : password , <EOL> '<STR_LIT>' : api_key , <EOL> '<STR_LIT>' : tenant , <EOL> '<STR_LIT>' : auth_url , <EOL> '<STR_LIT>' : region_name , <EOL> '<STR_LIT>' : os_auth_system <EOL> } <EOL> return suon . SaltNova ( ** kwargs ) <EOL> def boot ( name , flavor_id = <NUM_LIT:0> , image_id = <NUM_LIT:0> , profile = None , timeout = <NUM_LIT> ) : <EOL> '''<STR_LIT>''' <EOL> conn = _auth ( profile ) <EOL> return conn . boot ( name , flavor_id , image_id , timeout ) <EOL> def volume_list ( search_opts = None , profile = None ) : <EOL> '''<STR_LIT>''' <EOL> conn = _auth ( profile ) <EOL> return conn . volume_list ( search_opts = search_opts ) <EOL> def volume_show ( name , profile = None ) : <EOL> '''<STR_LIT>''' <EOL> conn = _auth ( profile ) <EOL> return conn . volume_show ( name ) <EOL> def volume_create ( name , size = <NUM_LIT:100> , snapshot = None , voltype = None , <EOL> profile = None ) : <EOL> '''<STR_LIT>''' <EOL> conn = _auth ( profile ) <EOL> return conn . volume_create ( <EOL> name , <EOL> size , <EOL> snapshot , <EOL> voltype <EOL> ) <EOL> def volume_delete ( name , profile = None ) : <EOL> '''<STR_LIT>''' <EOL> conn = _auth ( profile ) <EOL> return conn . volume_delete ( name ) <EOL> def volume_detach ( name , <EOL> profile = None , <EOL> timeout = <NUM_LIT> ) : <EOL> '''<STR_LIT>''' <EOL> conn = _auth ( profile ) <EOL> return conn . volume_detach ( <EOL> name , <EOL> timeout <EOL> ) <EOL> def volume_attach ( name , <EOL> server_name , <EOL> device = '<STR_LIT>' , <EOL> profile = None , <EOL> timeout = <NUM_LIT> ) : <EOL> '''<STR_LIT>''' <EOL> conn = _auth ( profile ) <EOL> return conn . volume_attach ( <EOL> name , <EOL> server_name , <EOL> device , <EOL> timeout <EOL> ) <EOL> def suspend ( instance_id , profile = None ) : <EOL> '''<STR_LIT>''' <EOL> conn = _auth ( profile ) <EOL> return conn . suspend ( instance_id ) <EOL> def resume ( instance_id , profile = None ) : <EOL> '''<STR_LIT>''' <EOL> conn = _auth ( profile ) <EOL> return conn . resume ( instance_id ) <EOL> def lock ( instance_id , profile = None ) : <EOL> '''<STR_LIT>''' <EOL> conn = _auth ( profile ) <EOL> return conn . lock ( instance_id ) <EOL> def delete ( instance_id , profile = None ) : <EOL> '''<STR_LIT>''' <EOL> conn = _auth ( profile ) <EOL> return conn . delete ( instance_id ) <EOL> def flavor_list ( profile = None ) : <EOL> '''<STR_LIT>''' <EOL> conn = _auth ( profile ) <EOL> return conn . flavor_list ( ) <EOL> def flavor_create ( name , <EOL> flavor_id = <NUM_LIT:0> , <EOL> ram = <NUM_LIT:0> , <EOL> disk = <NUM_LIT:0> , <EOL> vcpus = <NUM_LIT:1> , <EOL> profile = None ) : <EOL> '''<STR_LIT>''' <EOL> conn = _auth ( profile ) <EOL> return conn . flavor_create ( <EOL> name , <EOL> flavor_id , <EOL> ram , <EOL> disk , <EOL> vcpus <EOL> ) <EOL> def flavor_delete ( flavor_id , profile = None ) : <EOL> '''<STR_LIT>''' <EOL> conn = _auth ( profile ) <EOL> return conn . flavor_delete ( flavor_id ) <EOL> def keypair_list ( profile = None ) : <EOL> '''<STR_LIT>''' <EOL> conn = _auth ( profile ) <EOL> return conn . keypair_list ( ) <EOL> def keypair_add ( name , pubfile = None , pubkey = None , profile = None ) : <EOL> '''<STR_LIT>''' <EOL> conn = _auth ( profile ) <EOL> return conn . keypair_add ( <EOL> name , <EOL> pubfile , <EOL> pubkey <EOL> ) <EOL> def keypair_delete ( name , profile = None ) : <EOL> '''<STR_LIT>''' <EOL> conn = _auth ( profile ) <EOL> return conn . keypair_delete ( name ) <EOL> def image_list ( name = None , profile = None ) : <EOL> '''<STR_LIT>''' <EOL> conn = _auth ( profile ) <EOL> return conn . image_list ( name ) <EOL> def image_meta_set ( image_id = None , <EOL> name = None , <EOL> profile = None , <EOL> ** kwargs ) : <EOL> '''<STR_LIT>''' <EOL> conn = _auth ( profile ) <EOL> return conn . image_meta_set ( <EOL> image_id , <EOL> name , <EOL> ** kwargs <EOL> ) <EOL> def image_meta_delete ( image_id = None , <EOL> name = None , <EOL> keys = None , <EOL> profile = None ) : <EOL> '''<STR_LIT>''' <EOL> conn = _auth ( profile ) <EOL> return conn . image_meta_delete ( <EOL> image_id , <EOL> name , <EOL> keys <EOL> ) <EOL> def list_ ( profile = None ) : <EOL> '''<STR_LIT>''' <EOL> return server_list ( profile = profile ) <EOL> def server_list ( profile = None ) : <EOL> '''<STR_LIT>''' <EOL> conn = _auth ( profile ) <EOL> return conn . server_list ( ) <EOL> def show ( server_id , profile = None ) : <EOL> '''<STR_LIT>''' <EOL> return server_show ( server_id , profile ) <EOL> def server_list_detailed ( profile = None ) : <EOL> '''<STR_LIT>''' <EOL> conn = _auth ( profile ) <EOL> return conn . server_list_detailed ( ) <EOL> def server_show ( server_id , profile = None ) : <EOL> '''<STR_LIT>''' <EOL> conn = _auth ( profile ) <EOL> return conn . server_show ( server_id ) <EOL> def secgroup_create ( name , description , profile = None ) : <EOL> '''<STR_LIT>''' <EOL> conn = _auth ( profile ) <EOL> return conn . secgroup_create ( name , description ) <EOL> def secgroup_delete ( name , profile = None ) : <EOL> '''<STR_LIT>''' <EOL> conn = _auth ( profile ) <EOL> return conn . secgroup_delete ( name ) <EOL> def secgroup_list ( profile = None ) : <EOL> '''<STR_LIT>''' <EOL> conn = _auth ( profile ) <EOL> return conn . secgroup_list ( ) <EOL> def server_by_name ( name , profile = None ) : <EOL> '''<STR_LIT>''' <EOL> conn = _auth ( profile ) <EOL> return conn . server_by_name ( name ) </s>
