<s> '''<STR_LIT>''' <EOL> import ost_support <EOL> from actuator . provisioners . openstack import openstack_class_factory as ocf <EOL> from actuator . namespace import NamespaceModel , with_variables <EOL> ocf . set_neutron_client_class ( ost_support . MockNeutronClient ) <EOL> ocf . set_nova_client_class ( ost_support . MockNovaClient ) <EOL> from actuator import ( InfraModel , ProvisionerException , MultiResourceGroup , <EOL> MultiResource , ctxt , Var , ResourceGroup , Role , <EOL> MultiRole , NullTask , LOG_DEBUG , LOG_INFO , ConfigModel , <EOL> MultiTask , ConfigClassTask ) <EOL> from actuator . provisioners . openstack . resource_tasks import OpenstackProvisioner <EOL> from actuator . provisioners . openstack . resources import ( Server , Network , <EOL> Router , FloatingIP , <EOL> Subnet , SecGroup , <EOL> SecGroupRule , RouterGateway , <EOL> RouterInterface ) <EOL> from actuator . exec_agents . ansible . agent import AnsibleExecutionAgent <EOL> from actuator . modeling import AbstractModelReference <EOL> external_connection = ResourceGroup ( "<STR_LIT>" , <EOL> net = Network ( "<STR_LIT>" ) , <EOL> subnet = Subnet ( "<STR_LIT>" , <EOL> ctxt . comp . container . net , <EOL> u"<STR_LIT>" , <EOL> dns_nameservers = [ u'<STR_LIT>' ] ) , <EOL> router = Router ( "<STR_LIT>" ) , <EOL> gateway = RouterGateway ( "<STR_LIT>" , <EOL> ctxt . comp . container . router , <EOL> "<STR_LIT>" ) , <EOL> interface = RouterInterface ( "<STR_LIT>" , <EOL> ctxt . comp . container . router , <EOL> ctxt . comp . container . subnet ) ) <EOL> make_std_secgroup = ResourceGroup ( "<STR_LIT>" , <EOL> group = SecGroup ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ping_rule = SecGroupRule ( "<STR_LIT>" , <EOL> ctxt . comp . container . group , <EOL> ip_protocol = "<STR_LIT>" , <EOL> from_port = - <NUM_LIT:1> , to_port = - <NUM_LIT:1> ) , <EOL> ssh_rule = SecGroupRule ( "<STR_LIT>" , <EOL> ctxt . comp . container . group , <EOL> ip_protocol = "<STR_LIT>" , <EOL> from_port = <NUM_LIT> , to_port = <NUM_LIT> ) ) <EOL> ubuntu_img = "<STR_LIT>" <EOL> common_kwargs = { "<STR_LIT>" : "<STR_LIT>" } <EOL> def host_list ( ctx_exp , sep_char = "<STR_LIT:U+0020>" ) : <EOL> def host_list_inner ( ctx ) : <EOL> return sep_char . join ( [ h . host_ref . get_ip ( ) for h in ctx_exp ( ctx ) . values ( ) ] ) <EOL> return host_list_inner <EOL> def test001 ( ) : <EOL> class Infra ( InfraModel ) : <EOL> fip_pool = "<STR_LIT>" <EOL> gateway = external_connection <EOL> slave_secgroup = make_std_secgroup <EOL> slaves = MultiResourceGroup ( "<STR_LIT>" , <EOL> slave = Server ( "<STR_LIT>" , ubuntu_img , <EOL> "<STR_LIT>" , <EOL> nics = [ ctxt . model . gateway . net ] , <EOL> security_groups = [ ctxt . model . slave_secgroup . group ] , <EOL> ** common_kwargs ) , <EOL> slave_fip = FloatingIP ( "<STR_LIT>" , <EOL> ctxt . comp . container . slave , <EOL> ctxt . comp . container . slave . iface0 . addr0 , <EOL> pool = fip_pool ) ) <EOL> infra = Infra ( "<STR_LIT>" ) <EOL> class Namespace ( NamespaceModel ) : <EOL> with_variables ( Var ( "<STR_LIT>" , host_list ( ctxt . model . slaves ) ) ) <EOL> slaves = MultiRole ( Role ( "<STR_LIT>" , <EOL> host_ref = ctxt . model . infra . slaves [ ctxt . name ] . slave_fip , <EOL> variables = [ Var ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> Var ( "<STR_LIT>" , ctxt . name ) ] ) ) <EOL> ns = Namespace ( ) <EOL> class InnerConfig ( ConfigModel ) : <EOL> task = NullTask ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> class Config ( ConfigModel ) : <EOL> do_it = MultiTask ( "<STR_LIT>" , ConfigClassTask ( "<STR_LIT>" , InnerConfig ) , <EOL> Namespace . q . slaves . all ( ) ) <EOL> cfg = Config ( ) <EOL> uid = "<STR_LIT>" <EOL> pwd = "<STR_LIT>" <EOL> url = "<STR_LIT>" <EOL> os_prov = OpenstackProvisioner ( uid , pwd , uid , url , num_threads = <NUM_LIT:1> ) <EOL> for i in range ( <NUM_LIT:5> ) : <EOL> _ = ns . slaves [ i ] <EOL> ns . compute_provisioning_for_environ ( infra ) <EOL> _ = infra . refs_for_components ( ) <EOL> import traceback <EOL> try : <EOL> os_prov . provision_infra_model ( infra ) <EOL> except Exception , e : <EOL> print "<STR_LIT>" % e . message <EOL> for t , et , ev , tb in os_prov . agent . get_aborted_tasks ( ) : <EOL> print "<STR_LIT>" % t . name <EOL> traceback . print_exception ( et , ev , tb ) <EOL> print <EOL> assert False , "<STR_LIT>" <EOL> ea = AnsibleExecutionAgent ( config_model_instance = cfg , <EOL> namespace_model_instance = ns , <EOL> num_threads = <NUM_LIT:1> , <EOL> no_delay = True , log_level = LOG_DEBUG ) <EOL> try : <EOL> ea . perform_config ( ) <EOL> except Exception , e : <EOL> print "<STR_LIT>" % e . message <EOL> for t , et , ev , tb in ea . get_aborted_tasks ( ) : <EOL> print "<STR_LIT>" % t . name <EOL> traceback . print_exception ( et , ev , tb ) <EOL> print <EOL> assert False , "<STR_LIT>" <EOL> assert ( cfg . do_it . value ( ) . instances [ <NUM_LIT:0> ] . instance . task . get_task_role ( ) . host_ref is not None and <EOL> cfg . do_it . value ( ) . instances [ <NUM_LIT:0> ] . instance . task . get_task_host ( ) is not None and <EOL> isinstance ( cfg . do_it . value ( ) . instances [ <NUM_LIT:0> ] . instance . task . get_task_host ( ) , <EOL> basestring ) ) <EOL> def do_all ( ) : <EOL> for k , v in globals ( ) . items ( ) : <EOL> if k . startswith ( "<STR_LIT:test>" ) and callable ( v ) : <EOL> v ( ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> do_all ( ) </s>
