def create_security_group(self, name=None, description=None, **kwargs): rsp = self.request.invoke(callback=XmlParser.parser, Action='CreateSecurityGroup', GroupName=name, GroupDescription=description) validate_rsp(rsp, 'CreateSecurityGroup') return find_all(rsp, 'groupId')
def create_snapshot(self, disk=None, name=None, **kwargs): rsp = self.request.invoke(callback=XmlParser.parser, Action='CreateSnapshot', VolumeId=disk, **kwargs) validate_rsp(rsp) return find_all(rsp, "snapshotId")
def list_images(self, image_type=1): data = {} if image_type == 1: data['Filter.1.Name'] = 'is-public' data['Filter.1.Value.1'] = 'false' rsp = self.request.invoke(callback=XmlParser.parser, Action='DescribeImages', **data) validate_rsp(rsp, 'DescribeImages') return find_all(rsp, 'imageId')
def create_image(self, from_snapshot=None, from_instance=None, name=None, **kwargs): rsp = self.request.invoke(callback=XmlParser.parser, Action='CreateImage', InstanceId=from_instance, Name=name) validate_rsp(rsp, 'CreateImage') return find_all(rsp, 'imageId')[0]
def create_volume(self, name=None, snapshot=None, size=0, **kwargs): rsp = None if snapshot is not None or len(snapshot) > 0: rsp = self.request.invoke(callback=XmlParser.parser, Action='CreateVolume', SnapshotId=snapshot, **kwargs) elif size > 0: rsp = self.request.invoke(callback=XmlParser.parser, Action='CreateVolume', Size=size, **kwargs) else: raise RequestError(400, 'Invalid Request') validate_rsp(rsp, 'CreateVolume') return find_all(rsp, 'volumeId')[0]
def launch(self, image=None, flavor=None, hostname=None, bandwidth=None, **kwargs): """ :param image: image id :param flavor: InstanceType :param hostname: host name,not valid :param bandwidth: not valid :param kwargs: MaxCount,MinCount,KeyName :return: """ rsp = self.request.invoke(callback=XmlParser.parser, Action='RunInstances', ImageId=image, MaxCount=1, MinCount=1, InstanceType=flavor, **kwargs) validate_rsp(rsp, 'RunInstances') return find_all(rsp, 'instanceId')
def launch(self, image=None, flavor=None, hostname=None, bandwidth=None, **kwargs): """ :param image: image id :param flavor: InstanceType :param hostname: host name,not valid :param bandwidth: not valid :param kwargs: MaxCount,MinCount,KeyName :return: """ rsp = self.request.invoke( callback=XmlParser.parser, Action="RunInstances", ImageId=image, MaxCount=1, MinCount=1, InstanceType=flavor, **kwargs ) validate_rsp(rsp, "RunInstances") return find_all(rsp, "instanceId")
def query_image(self, name=None, **kwargs): rsp = self.request.invoke(callback=XmlParser.parser, Action='DescribeImages') validate_rsp(rsp, 'DescribeImages') return find_all(rsp, 'imageName')
def list_snapshot(self, instance=None, disk=None, **kwargs): rsp = self.request.invoke(callback=XmlParser.parser, Action='DescribeSnapshots') validate_rsp(rsp) return find_all(rsp, "snapshotId")
def list_instances(self): rsp = self.request.invoke(callback=XmlParser.parser, Action='DescribeInstances') validate_rsp(rsp, 'DescribeInstances') return find_all(rsp, 'instanceId')
def list_regions(self): rsp = self.request.invoke(callback=XmlParser.parser, Action='DescribeRegions') validate_rsp(rsp, 'DescribeRegions') return find_all(rsp, 'regionName')
def list_security_group(self): rsp = self.request.invoke(callback=XmlParser.parser, Action='DescribeSecurityGroups') validate_rsp(rsp, 'DescribeSecurityGroups') return find_all(rsp, 'groupId')
def list_volume(self): rsp = self.request.invoke(Action='DescribeVolumes', callback=XmlParser.parser) validate_rsp(rsp, 'DescribeVolumes') return find_all(rsp, 'volumeId')
def list_zones(self): rsp = self.request.invoke(callback=XmlParser.parser, Action='DescribeAvailabilityZones') validate_rsp(rsp, 'DescribeAvailabilityZones') return find_all(rsp, 'zoneName')
def list_instances(self): rsp = self.request.invoke(callback=XmlParser.parser, Action="DescribeInstances") validate_rsp(rsp, "DescribeInstances") return find_all(rsp, "instanceId")