def get_cloudbaseinit_traceback(self): code = util.get_resource('windows/get_traceback.ps1') remote_script = "C:\\{}.ps1".format(util.rand_name()) with _create_tempfile(content=code) as tmp: self.remote_client.copy_file(tmp, remote_script) stdout = self.remote_client.run_command_verbose( remote_script, command_type=util.POWERSHELL) return stdout.strip()
def get_user_flags(self, user): code = util.get_resource('windows/get_user_flags.ps1') remote_script = "C:\\{}.ps1".format(util.rand_name()) with _create_tempfile(content=code) as tmp: self.remote_client.copy_file(tmp, remote_script) stdout = self.remote_client.run_command_verbose( "powershell {0} {1}".format(remote_script, user)) return stdout.strip()
def get_cloudbaseinit_traceback(self): code = util.get_resource('windows/get_traceback.ps1') remote_script = "C:\\{}.ps1".format(util.rand_name()) with _create_tempfile(content=code) as tmp: self.remote_client.copy_file(tmp, remote_script) stdout = self.remote_client.run_command_verbose( "powershell " + remote_script) return stdout.strip()
def get_cloudbaseinit_traceback(self): code = util.get_resource('windows/get_traceback.ps1') remote_script = "C:\\{}.ps1".format(util.rand_name()) with _create_tempfile(content=code) as tmp: self.remote_client.copy_file(tmp, remote_script) stdout = self.remote_client.run_command_verbose( remote_script, command_type=util.POWERSHELL_SCRIPT_REMOTESIGNED) return stdout.strip()
def get_user_flags(self, user): code = util.get_resource('windows/get_user_flags.ps1') remote_script = "C:\\{}.ps1".format(util.rand_name()) with _create_tempfile(content=code) as tmp: self.remote_client.copy_file(tmp, remote_script) stdout = self.remote_client.run_command_verbose( "{0} {1}".format(remote_script, user), command_type=util.POWERSHELL_SCRIPT_BYPASS) return stdout.strip()
def _create_server(self, wait_until='ACTIVE', **kwargs): server = self._manager.servers_client.create_server( name=util.rand_name(self._name) + "-instance", imageRef=self.image_ref, flavorRef=self.flavor_ref, **kwargs) waiters.wait_for_server_status( self._manager.servers_client, server['server']['id'], wait_until) return server['server']
def _create_server(self, wait_until='ACTIVE', **kwargs): for key, value in list(kwargs.items()): if not value: del kwargs[key] server = self._manager.servers_client.create_server( name=util.rand_name(self._name) + "-instance", imageRef=self.image_ref, flavorRef=self.flavor_ref, **kwargs) waiters.wait_for_server_status(self._manager.servers_client, server['server']['id'], wait_until) return server['server']
def _create_security_groups(self): sg_name = util.rand_name(self.__class__.__name__) sg_desc = sg_name + " description" secgroup = self._manager.security_groups_client.create_security_group( name=sg_name, description=sg_desc)['security_group'] # Add rules to the security group. for rule in self._add_security_group_exceptions(secgroup['id']): self._security_groups_rules.append(rule['id']) self._manager.servers_client.add_security_group( server_id=self.internal_instance_id(), name=secgroup['name']) return secgroup
def _create_server(self, wait_until='ACTIVE', **kwargs): for key, value in list(kwargs.items()): if not value: del kwargs[key] server = self._manager.servers_client.create_server( name=util.rand_name(self._name) + "-instance", imageRef=self.image_ref, flavorRef=self.flavor_ref, **kwargs) waiters.wait_for_server_status( self._manager.servers_client, server['server']['id'], wait_until) return server['server']
def _create_private_network(self): """Create an extra private network to be attached. This network is the one with disabled DHCP and ready for static configuration by Cloudbase-Init. """ tenant_id = self._manager.primary_credentials().tenant_id # pylint: disable=protected-access net_resources = self._manager.isolated_creds._create_network_resources( tenant_id) # Store the network for later cleanup. key = "fake" fake_net_creds = util.get_namedtuple( "FakeCreds", ("network", "subnet", "router", "user_id", "tenant_id", "username", "tenant_name"), net_resources + (None,) * 4) self._manager.isolated_creds._creds[key] = fake_net_creds # Disable DHCP for this network to test static configuration and # also add default DNS name servers. subnet_id = fake_net_creds.subnet["id"] subnets_client = self._manager.subnets_client subnets_client.update_subnet( subnet_id, enable_dhcp=False, dns_nameservers=CONFIG.argus.dns_nameservers) # Change the allocation pool to configure any IP, # other the one used already with dynamic settings. allocation_pools = subnets_client.show_subnet(subnet_id)["subnet"][ "allocation_pools"] allocation_pools[0]["start"] = util.next_ip( allocation_pools[0]["start"], step=2) subnets_client.update_subnet(subnet_id, allocation_pools=allocation_pools) # Create and attach an IPv6 subnet for this network. Also, register # it for later cleanup. subnet6_name = util.rand_name(self.__class__.__name__) + "-subnet6" network_id = fake_net_creds.network["id"] subnets_client.create_subnet( network_id=network_id, cidr=SUBNET6_CIDR, name=subnet6_name, dns_nameservers=DNSES6, tenant_id=tenant_id, enable_dhcp=False, ip_version=6)
def _create_private_network(self): """Create an extra private network to be attached. This network is the one with disabled DHCP and ready for static configuration by Cloudbase-Init. """ tenant_id = self._manager.primary_credentials().tenant_id # pylint: disable=protected-access net_resources = self._manager.isolated_creds._create_network_resources( tenant_id) # Store the network for later cleanup. key = "fake" fake_net_creds = util.get_namedtuple( "FakeCreds", ("network", "subnet", "router", "user_id", "tenant_id", "username", "tenant_name"), net_resources + (None, ) * 4) self._manager.isolated_creds._creds[key] = fake_net_creds # Disable DHCP for this network to test static configuration and # also add default DNS name servers. subnet_id = fake_net_creds.subnet["id"] subnets_client = self._manager.subnets_client subnets_client.update_subnet( subnet_id, enable_dhcp=False, dns_nameservers=CONFIG.argus.dns_nameservers) # Change the allocation pool to configure any IP, # other the one used already with dynamic settings. allocation_pools = subnets_client.show_subnet( subnet_id)["subnet"]["allocation_pools"] allocation_pools[0]["start"] = util.next_ip( allocation_pools[0]["start"], step=2) subnets_client.update_subnet(subnet_id, allocation_pools=allocation_pools) # Create and attach an IPv6 subnet for this network. Also, register # it for later cleanup. subnet6_name = util.rand_name(self.__class__.__name__) + "-subnet6" network_id = fake_net_creds.network["id"] subnets_client.create_subnet(network_id=network_id, cidr=SUBNET6_CIDR, name=subnet6_name, dns_nameservers=DNSES6, tenant_id=tenant_id, enable_dhcp=False, ip_version=6)