def run(self, count=None, region=None, metadata=None): if region: cs = self.pyrax.connect_to_cloudservers(region=region) else: cs = self.pyrax.cloudservers servers = cs.list() result = [] for server in servers: item = to_server_dict(server=server) if metadata: include = self._metadata_intersection(server=item, metadata=metadata) if not include: continue result.append(item['name']) if count: return result[0:count] else: return result
def run(self, count=None, region=None, metadata=None): if region: cs = self.pyrax.connect_to_cloudservers(region=region) else: cs = self.pyrax.cloudservers servers = cs.list() result = [] for server in servers: item = to_server_dict(server=server) if metadata: include = self._metadata_intersection(server=item, metadata=metadata) if not include: continue public_ips = item.get('public_ips', []) result.extend(public_ips) if count: return result[0:count] else: return result
def run(self, name, image_id, flavor_id, key_material=None, metadata=None, region=None): if region: cs = self.pyrax.connect_to_cloudservers(region=region) else: cs = self.pyrax.cloudservers image = cs.images.get(image_id) flavor = cs.flavors.get(flavor_id) if key_material: key_name = 'key-%s' % (random.randint(1, 100000)) key_pair = cs.keypairs.create(key_name, key_material) else: key_name = None self.logger.info('Creating server...') server = cs.servers.create(name=name, image=image, flavor=flavor, key_name=key_name, meta=metadata) # Block until provisioned self.pyrax.utils.wait_for_build(server) self.logger.info('Server successfully created: %s' % (server)) result = to_server_dict(server=server) return result
def run(self, vm_id, region=None): if region: cs = self.pyrax.connect_to_cloudservers(region=region) else: cs = self.pyrax.cloudservers for server in cs.list(): item = to_server_dict(server=server) if server.id == vm_id: return item return None
def run(self, ip_address, region=None): if region: cs = self.pyrax.connect_to_cloudservers(region=region) else: cs = self.pyrax.cloudservers servers = cs.list() result = None for server in servers: item = to_server_dict(server=server) public_ips = item.get('public_ips', []) if ip_address in public_ips: result = item break return result