def attach_volume(self, instance=None, volume=None, device=None, **kwargs): rsp = self.request.invoke(Action='AttachVolume', callback=XmlParser.parser, InstanceId=instance, VolumeId=volume, **kwargs) validate_rsp(rsp, 'AttachVolume')
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 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 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 remove_image(self, image): rsp = self.request.invoke(callback=XmlParser.parser, Action='DeregisterImage', ImageId=image) validate_rsp(rsp)
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 remove_snapshot(self, snapshot): rsp = self.request.invoke(callback=XmlParser.parser, Action='DeleteSnapshot', SnapshotId=snapshot) validate_rsp(rsp)
def remove_volume(self, volume): rsp = self.request.invoke(Action='DeleteVolume', callback=XmlParser.parser, VolumeId=volume) validate_rsp(rsp, 'DeleteVolume')
def list_instances(self): rsp = self.request.invoke(callback=XmlParser.parser, Action='DescribeInstances') validate_rsp(rsp, 'DescribeInstances') return find_all(rsp, 'instanceId')
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 detach_volume(self, instance=None, volume=None): rsp = self.request.invoke(Action='DetachVolume', callback=XmlParser.parser, InstanceId=instance, VolumeId=volume) validate_rsp(rsp, 'DetachVolume')
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_regions(self): rsp = self.request.invoke(callback=XmlParser.parser, Action='DescribeRegions') validate_rsp(rsp, 'DescribeRegions') return find_all(rsp, 'regionName')
def stop(self, instance, force=False): data = {'InstanceId.1': instance} rsp = self.request.invoke(callback=XmlParser.parser, Action='TerminateInstances', **data) validate_rsp(rsp, 'TerminateInstances')
def remove_instance(self, instance): data = {'InstanceId.1': instance} rsp = self.request.invoke(callback=XmlParser.parser, Action='StopInstances', **data) validate_rsp(rsp, 'StopInstances')
def remove_security_group(self, group): rsp = self.request.invoke(callback=XmlParser.parser, Action='DeleteSecurityGroup', GroupId=group) validate_rsp(rsp, 'DeleteSecurityGroup')
def list_instances(self): rsp = self.request.invoke(callback=XmlParser.parser, Action="DescribeInstances") validate_rsp(rsp, "DescribeInstances") return find_all(rsp, "instanceId")
def list_security_group(self): rsp = self.request.invoke(callback=XmlParser.parser, Action='DescribeSecurityGroups') validate_rsp(rsp, 'DescribeSecurityGroups') return find_all(rsp, 'groupId')
def stop(self, instance, force=False): data = {"InstanceId.1": instance} rsp = self.request.invoke(callback=XmlParser.parser, Action="TerminateInstances", **data) validate_rsp(rsp, "TerminateInstances")
def remove_instance(self, instance): data = {"InstanceId.1": instance} rsp = self.request.invoke(callback=XmlParser.parser, Action="StopInstances", **data) validate_rsp(rsp, "StopInstances")