def __import_key_pair_cb__(self, kwargs, callback):
     try:
         ret = self.clc.import_key_pair(kwargs['key_name'],
                                        kwargs['public_key_material'])
         Threads.instance().invokeCallback(callback, Response(data=ret))
     except Exception as ex:
         Threads.instance().invokeCallback(callback, Response(error=ex))
 def __associate_address_cb__(self, kwargs, callback):
     try:
         ret = self.clc.associate_address(kwargs['publicip'],
                                          kwargs['instanceid'])
         Threads.instance().invokeCallback(callback, Response(data=ret))
     except Exception as ex:
         Threads.instance().invokeCallback(callback, Response(error=ex))
 def __get_all_key_pairs_cb__(self, kwargs, callback):
     try:
         self.keypairs.values = self.clc.get_all_key_pairs()
         Threads.instance().invokeCallback(
             callback, Response(data=self.keypairs.values))
     except Exception as ex:
         Threads.instance().invokeCallback(callback, Response(error=ex))
 def __stop_instances_cb__(self, kwargs, callback):
     try:
         ret = self.clc.stop_instances(kwargs['instance_ids'],
                                       kwargs['force'])
         Threads.instance().invokeCallback(callback, Response(data=ret))
     except Exception as ex:
         Threads.instance().invokeCallback(callback, Response(error=ex))
 def associate_address(self, publicip, instanceid, callback):
     self.addresses.expireCache()
     Threads.instance().runThread(self.__associate_address_cb__,
                                  ({
                                      'publicip': publicip,
                                      'instanceid': instanceid
                                  }, callback))
 def __create_security_group_cb__(self, kwargs, callback):
     try:
         ret = self.clc.create_security_group(kwargs['name'],
                                              kwargs['description'])
         Threads.instance().invokeCallback(callback, Response(data=ret))
     except Exception as ex:
         Threads.instance().invokeCallback(callback, Response(error=ex))
 def stop_instances(self, instance_ids, force=False, callback=None):
     self.instances.expireCache()
     Threads.instance().runThread(self.__stop_instances_cb__,
                                  ({
                                      'instance_ids': instance_ids,
                                      'force': force
                                  }, callback))
 def __get_all_images_cb__(self, kwargs, callback):
     try:
         self.images.values = self.clc.get_all_images(kwargs['owners'])
         Threads.instance().invokeCallback(
             callback, Response(data=self.images.values))
     except Exception as ex:
         Threads.instance().invokeCallback(callback, Response(error=ex))
 def reset_image_attribute(self, image_id, attribute):
     self.images.expireCache()
     Threads.instance().runThread(self.__reset_image_attribute_cb__,
                                  ({
                                      'image_id': image_id,
                                      'attribute': attribute
                                  }, callback))
示例#10
0
 def __get_all_buckets_cb__(self, kwargs, callback):
     try:
         self.caches['buckets'].values = self.walrus.get_all_buckets()
         Threads.instance().invokeCallback(
             callback, Response(data=self.caches['buckets'].values))
     except Exception as ex:
         Threads.instance().invokeCallback(callback, Response(error=ex))
 def get_all_zones(self, callback):
     # if cache stale, update it
     if self.zones.isCacheStale():
         Threads.instance().runThread(self.__get_all_zones_cb__,
                                      ({}, callback))
     else:
         callback(Response(data=self.zones.values))
示例#12
0
 def __get_all_tags_cb__(self, kwargs, callback):
     try:
         ret = self.clc.get_all_tags(kwargs['filters'])
         self.caches['tags'].values = ret
         Threads.instance().invokeCallback(callback, Response(data=ret))
     except Exception as ex:
         Threads.instance().invokeCallback(callback, Response(error=ex))
示例#13
0
 def reset_snapshot_attribute(self, snapshot_id, attribute, callback):
     self.caches['snapshots'].expireCache()
     Threads.instance().runThread(self.__reset_snapshot_attribute_cb__,
                                  ({
                                      'snapshot_id': snapshot_id,
                                      'attribute': attribute
                                  }, callback))
示例#14
0
 def __create_snapshot_cb__(self, kwargs, callback):
     try:
         ret = self.clc.create_snapshot(kwargs['volume_id'],
                                        kwargs['description'])
         Threads.instance().invokeCallback(callback, Response(data=ret))
     except Exception as ex:
         Threads.instance().invokeCallback(callback, Response(error=ex))
 def __get_all_security_groups_cb__(self, kwargs, callback):
     try:
         self.groups.values = self.clc.get_all_security_groups()
         Threads.instance().invokeCallback(
             callback, Response(data=self.groups.values))
     except Exception as ex:
         Threads.instance().invokeCallback(callback, Response(error=ex))
 def __reset_image_attribute_cb__(self, kwargs, callback):
     try:
         ret = self.clc.reset_image_attribute(kwargs['image_id'],
                                              kwargs['attribute'])
         Threads.instance().invokeCallback(callback, Response(data=ret))
     except Exception as ex:
         Threads.instance().invokeCallback(callback, Response(error=ex))
 def create_security_group(self, name, description, callback):
     self.groups.expireCache()
     Threads.instance().runThread(self.__create_security_group_cb__,
                                  ({
                                      'name': name,
                                      'description': description
                                  }, callback))
 def __get_all_regions_cb__(self, kwargs, callback):
     try:
         ret = self.clc.get_all_regions(kwargs['filters'])
         logging.info("regions = "+str(ret))
         Threads.instance().invokeCallback(callback, Response(data=ret))
     except Exception as ex:
         Threads.instance().invokeCallback(callback, Response(error=ex))
示例#19
0
 def register_image(self, name, image_location=None, description=None, architecture=None, kernel_id=None, ramdisk_id=None, root_dev_name=None, block_device_map=None, callback=None):
     self.caches['images'].expireCache()
     Threads.instance().runThread(self.__register_image_cb__,
                         ({'name':name, 'image_location':image_location, 'description':description,
                           'architecture':architecture, 'kernel_id':kernel_id,
                           'ramdisk_id':ramdisk_id, 'root_dev_name':root_dev_name,
                           'block_device_map':block_device_map}, callback))
 def get_all_tags(self, filters=None, max_records=None, next_token=None, callback=None):
     if self.tags.isCacheStale():
         params = {'filters':filters,
                   'max_records':max_records, 'next_token':next_token}
         Threads.instance().runThread(self.__get_all_tags_cb__, (params, callback))
     else:
         callback(Response(data=self.tags.values))
示例#21
0
 def run_instances(self, image_id, min_count=1, max_count=1,
                   key_name=None, security_groups=None,
                   user_data=None, addressing_type=None,
                   instance_type='m1.small', placement=None,
                   kernel_id=None, ramdisk_id=None,
                   monitoring_enabled=False, subnet_id=None,
                   block_device_map=None,
                   disable_api_termination=False,
                   instance_initiated_shutdown_behavior=None,
                   private_ip_address=None,
                   placement_group=None, client_token=None,
                   security_group_ids=None,
                   additional_info=None, instance_profile_name=None,
                   instance_profile_arn=None, tenancy=None, callback=None):
     self.caches['instances'].expireCache()
     Threads.instance().runThread(self.__run_instances_cb__,
                 ({'image_id':image_id, 'min_count':min_count, 'max_count':max_count,
                   'key_name':key_name, 'security_groups':security_groups,
                   'user_data':user_data, 'addressing_type':addressing_type,
                   'instance_type':instance_type, 'placement':placement,
                   'kernel_id':kernel_id, 'ramdisk_id':ramdisk_id,
                   'monitoring_enabled':monitoring_enabled, 'subnet_id':subnet_id,
                   'block_device_map':block_device_map,
                   'disable_api_termination':disable_api_termination,
                   'instance_initiated_shutdown_behavior':instance_initiated_shutdown_behavior,
                   'private_ip_address':private_ip_address,
                   'placement_group':placement_group, 'client_token':client_token,
                   'security_group_ids':security_group_ids,
                   'additional_info':additional_info,
                   'instance_profile_name':instance_profile_name,
                   'instance_profile_arn':instance_profile_arn,
                   'tenancy':tenancy}, callback))
示例#22
0
 def revoke_security_group(self,
                           name=None,
                           src_security_group_name=[],
                           src_security_group_owner_id=[],
                           ip_protocol=[],
                           from_port=[],
                           to_port=[],
                           cidr_ip=[],
                           group_id=[],
                           src_security_group_group_id=[],
                           callback=None):
     self.caches['groups'].expireCache()
     Threads.instance().runThread(
         self.__revoke_security_group_cb__,
         ({
             'name': name,
             'src_security_group_name': src_security_group_name,
             'src_security_group_owner_id': src_security_group_owner_id,
             'ip_protocol': ip_protocol,
             'from_port': from_port,
             'to_port': to_port,
             'cidr_ip': cidr_ip,
             'group_id': group_id,
             'src_security_group_group_id': src_security_group_group_id
         }, callback))
示例#23
0
 def __get_all_instances_cb__(self, kwargs, callback):
     try:
         self.instances.values = self.clc.get_all_instances()
         Threads.instance().invokeCallback(callback,
                         Response(data=self.__normalize_instances__(self.instances.values)))
     except Exception as ex:
         Threads.instance().invokeCallback(callback, Response(error=ex))
示例#24
0
 def __modify_snapshot_attribute_cb__(self, kwargs, callback):
     try:
         ret = self.clc.modify_snapshot_attribute(kwargs['snapshot_id'], kwargs['attribute'],
                                 kwargs['operation'], kwargs['user'], kwargs['groups'])
         Threads.instance().invokeCallback(callback, Response(data=ret))
     except Exception as ex:
         Threads.instance().invokeCallback(callback, Response(error=ex))
 def __get_all_groups_cb__(self, kwargs, callback):
     try:
         self.groups.values = self.scaling.get_all_groups(kwargs['names'],
                                 kwargs['max_records'], kwargs['next_token'])
         Threads.instance().invokeCallback(callback, Response(data=self.groups.values))
     except Exception as ex:
         Threads.instance().invokeCallback(callback, Response(error=ex))
 def __describe_alarms_cb__(self, kwargs, callback):
     try:
         self.caches['alarms'].values = self.cw.describe_alarms(kwargs['action_prefix'], kwargs['alarm_name_prefix'], kwargs['alarm_names'],
                                                      kwargs['max_records'], kwargs['state_value'], kwargs['next_token'])
         Threads.instance().invokeCallback(callback, Response(data=self.caches['alarms'].values))
     except Exception as ex:
         Threads.instance().invokeCallback(callback, Response(error=ex))
示例#27
0
 def __get_all_tags_cb__(self, kwargs, callback):
     try:
         ret = self.clc.get_all_tags(kwargs['filters'])
         self.caches['tags'].values = ret
         Threads.instance().invokeCallback(callback, Response(data=ret))
     except Exception as ex:
         Threads.instance().invokeCallback(callback, Response(error=ex))
 def get_all_policies(self, as_group=None, policy_names=None, max_records=None, next_token=None, callback=None):
     if self.caches['policies'].isCacheStale():
         params = {'as_group':as_group, 'policy_names':policy_names,
                   'max_records':max_records, 'next_token':next_token}
         Threads.instance().runThread(self.__get_all_policies_cb__, (params, callback))
     else:
         callback(Response(data=self.caches['policies'].values))
 def __terminate_instance_cb__(self, kwargs, callback):
     try:
         ret = self.scaling.terminate_instance(kwargs['instance_id'],
                         kwargs['decrement_capacity'])
         Threads.instance().invokeCallback(callback, Response(data=ret))
     except Exception as ex:
         Threads.instance().invokeCallback(callback, Response(error=ex))
 def __get_all_launch_configurations_cb__(self, kwargs, callback):
     try:
         self.caches['launchconfigs'].values = self.scaling.get_all_launch_configurations(
                              kwargs['names'], kwargs['max_records'], kwargs['next_token'])
         Threads.instance().invokeCallback(callback, Response(data=self.caches['launchconfigs'].values))
     except Exception as ex:
         Threads.instance().invokeCallback(callback, Response(error=ex))
 def __set_desired_capacity_cb__(self, kwargs, callback):
     try:
         ret = self.scaling.set_desired_capacity(kwargs['group_name'],
                         kwargs['desired_capacity'], kwargs['honor_cooldown'])
         Threads.instance().invokeCallback(callback, Response(data=ret))
     except Exception as ex:
         Threads.instance().invokeCallback(callback, Response(error=ex))
 def __set_instance_health_cb__(self, kwargs, callback):
     try:
         ret = self.scaling.set_instance_health(kwargs['instance_id'],
                         kwargs['health_status'], kwargs['should_respect_grace_period'])
         Threads.instance().invokeCallback(callback, Response(data=ret))
     except Exception as ex:
         Threads.instance().invokeCallback(callback, Response(error=ex))
 def __list_metrics_cb__(self, kwargs, callback):
     try:
         self.metrics.values = self.cw.list_metrics(kwargs['next_token'], kwargs['dimensions'],
                                    kwargs['metric_name'], kwargs['namespace'])
         Threads.instance().invokeCallback(callback, Response(data=self.metrics.values))
     except Exception as ex:
         Threads.instance().invokeCallback(callback, Response(error=ex))
示例#34
0
 def create_snapshot(self, volume_id, description, callback):
     self.caches['snapshots'].expireCache()
     Threads.instance().runThread(self.__create_snapshot_cb__,
                                  ({
                                      'volume_id': volume_id,
                                      'description': description
                                  }, callback))
 def __create_load_balancer_cb__(self, kwargs, callback):
     try:
         ret = self.bal.create_load_balancer(kwargs['name'], kwargs['zones'], kwargs['listeners'],
                                 kwargs['subnets'], kwargs['security_groups'], kwargs['scheme'])
         Threads.instance().invokeCallback(callback, Response(data=ret))
     except Exception as ex:
         Threads.instance().invokeCallback(callback, Response(error=ex))
示例#36
0
 def get_all_zones(self, filters, callback):
     # if cache stale, update it
     if self.caches['zones'].isCacheStale(filters):
         Threads.instance().runThread(self.__get_all_zones_cb__, ({'filters':filters}, callback))
         self.caches['zones'].filters = filters
     else:
         callback(Response(data=self.caches['zones'].values))
示例#37
0
 def __get_metric_statistics_cb__(self, kwargs, callback):
     try:
         ret = self.cw.get_metric_statistics(kwargs['period'], kwargs['start_time'], kwargs['end_time'],
                         kwargs['metric_name'], kwargs['namespace'], kwargs['statistics'],
                         kwargs['dimensions'], kwargs['unit'])
         Threads.instance().invokeCallback(callback, Response(data=ret))
     except Exception as ex:
         Threads.instance().invokeCallback(callback, Response(error=ex))
 def __put_metric_data_cb__(self, kwargs, callback):
     try:
         ret = self.cw.put_metric_data(kwargs['namespace'], kwargs['name'], kwargs['value'],
                                    kwargs['timestamp'], kwargs['unit'], kwargs['dimensions'],
                                    kwargs['statistics'])
         Threads.instance().invokeCallback(callback, Response(data=ret))
     except Exception as ex:
         Threads.instance().invokeCallback(callback, Response(error=ex))
 def describe_alarms(self, action_prefix=None, alarm_name_prefix=None, alarm_names=None, max_records=None,
                     state_value=None, next_token=None, callback=None):
     if self.caches['alarms'].isCacheStale():
         params = {'action_prefix':action_prefix, 'alarm_name_prefix':alarm_name_prefix, 'alarm_names':alarm_names,
                   'max_records':max_records, 'state_value':state_value, 'next_token':next_token}
         Threads.instance().runThread(self.__describe_alarms_cb__, (params, callback))
     else:
         callback(Response(data=self.caches['alarms'].values))
 def __get_all_load_balancers_cb__(self, kwargs, callback):
     try:
         self.balancers.values = self.bal.get_all_load_balancers(
             kwargs['load_balancer_names'])
         Threads.instance().invokeCallback(
             callback, Response(data=self.balancers.values))
     except Exception as ex:
         Threads.instance().invokeCallback(callback, Response(error=ex))
 def create_volume(self, size, availability_zone, snapshot_id, callback):
     self.caches['volumes'].expireCache()
     Threads.instance().runThread(
         self.__create_volume_cb__, ({
             'size': size,
             'availability_zone': availability_zone,
             'snapshot_id': snapshot_id
         }, callback))
 def delete_security_group(self, name=None, group_id=None, callback=None):
     # invoke this on a separate thread
     self.caches['groups'].expireCache()
     Threads.instance().runThread(self.__delete_security_group_cb__,
                                  ({
                                      'name': name,
                                      'group_id': group_id
                                  }, callback))
 def import_key_pair(self, key_name, public_key_material, callback):
     self.caches['keypairs'].expireCache()
     Threads.instance().runThread(
         self.__import_key_pair_cb__,
         ({
             'key_name': key_name,
             'public_key_material': public_key_material
         }, callback))
 def __get_all_launch_configurations_cb__(self, kwargs, callback):
     try:
         self.launchconfigs.values = self.scaling.get_all_launch_configurations(
             kwargs['names'], kwargs['max_records'], kwargs['next_token'])
         Threads.instance().invokeCallback(
             callback, Response(data=self.launchconfigs.values))
     except Exception as ex:
         Threads.instance().invokeCallback(callback, Response(error=ex))
 def __create_load_balancer_cb__(self, kwargs, callback):
     try:
         ret = self.bal.create_load_balancer(
             kwargs['name'], kwargs['zones'], kwargs['listeners'],
             kwargs['subnets'], kwargs['security_groups'], kwargs['scheme'])
         Threads.instance().invokeCallback(callback, Response(data=ret))
     except Exception as ex:
         Threads.instance().invokeCallback(callback, Response(error=ex))
 def __attach_volume_cb__(self, kwargs, callback):
     try:
         ret = self.clc.attach_volume(kwargs['volume_id'],
                                      kwargs['instance_id'],
                                      kwargs['device'])
         Threads.instance().invokeCallback(callback, Response(data=ret))
     except Exception as ex:
         Threads.instance().invokeCallback(callback, Response(error=ex))
 def __create_volume_cb__(self, kwargs, callback):
     try:
         ret = self.clc.create_volume(kwargs['size'],
                                      kwargs['availability_zone'],
                                      kwargs['snapshot_id'])
         Threads.instance().invokeCallback(callback, Response(data=ret))
     except Exception as ex:
         Threads.instance().invokeCallback(callback, Response(error=ex))
 def get_all_autoscaling_instances(self, instance_ids=None, max_records=None, next_token=None, callback=None):
     if self.instances.isCacheStale():
         params = {'instance_ids':instance_ids, 'max_records':max_records,
                   'next_token':next_token}
         Threads.instance().runThread(self.__get_all_autoscaling_instances_cb__,
                                 (params, callback))
     else:
         callback(Response(data=self.instances.values))
 def attach_volume(self, volume_id, instance_id, device, callback):
     self.caches['volumes'].expireCache()
     Threads.instance().runThread(self.__attach_volume_cb__,
                                  ({
                                      'volume_id': volume_id,
                                      'instance_id': instance_id,
                                      'device': device
                                  }, callback))
 def __get_all_autoscaling_instances_cb__(self, kwargs, callback):
     try:
         self.caches['scalinginsts'].values = self.scaling.get_all_autoscaling_instances(
                                         kwargs['instance_ids'],
                                         kwargs['max_records'], kwargs['next_token'])
         Threads.instance().invokeCallback(callback, Response(data=self.caches['scalinginsts'].values))
     except Exception as ex:
         Threads.instance().invokeCallback(callback, Response(error=ex))
 def delete_auto_scaling_group(self,
                               name,
                               force_delete=False,
                               callback=None):
     self.groups.expireCache()
     params = {'name': name, 'force_delete': force_delete}
     Threads.instance().runThread(self.__delete_auto_scaling_group_cb__,
                                  (params, callback))
示例#52
0
 def __register_image_cb__(self, kwargs, callback):
     try:
         ret = self.clc.register_image(kwargs['name'], kwargs['image_location'], kwargs['description'],
                                       kwargs['architecture'], kwargs['kernel_id'], kwargs['ramdisk_id'],
                                       kwargs['root_dev_name'], kwargs['block_device_map'])
         Threads.instance().invokeCallback(callback, Response(data=ret))
     except Exception as ex:
         Threads.instance().invokeCallback(callback, Response(error=ex))
示例#53
0
 def __get_password_cb__(self, kwargs, callback):
     try:
         passwd_data = self.user_session.clc.get_password_data(kwargs['instanceid'])
         priv_key_file = self.request.files['priv_key']
         user_priv_key = RSA.load_key_string(priv_key_file[0].body)
         string_to_decrypt = base64.b64decode(passwd_data)
         ret = user_priv_key.private_decrypt(string_to_decrypt, RSA.pkcs1_padding)
         ret = {'instance':kwargs['instanceid'], 'password': ret}
         Threads.instance().invokeCallback(callback, eucaconsole.cachingclcinterface.Response(data=ret))
     except Exception as ex:
         traceback.print_exc(file=sys.stdout)
         Threads.instance().invokeCallback(callback, eucaconsole.cachingclcinterface.Response(error=ex))
示例#54
0
 def revoke_security_group(self, name=None,
                              src_security_group_name=[],
                              src_security_group_owner_id=[],
                              ip_protocol=[], from_port=[], to_port=[],
                              cidr_ip=[], group_id=[],
                              src_security_group_group_id=[], callback=None):
     self.caches['groups'].expireCache()
     Threads.instance().runThread(self.__revoke_security_group_cb__,
                 ({'name':name, 'src_security_group_name':src_security_group_name,
                   'src_security_group_owner_id':src_security_group_owner_id,
                   'ip_protocol':ip_protocol, 'from_port':from_port,
                   'to_port':to_port, 'cidr_ip':cidr_ip, 'group_id':group_id,
                   'src_security_group_group_id':src_security_group_group_id}, callback))
示例#55
0
 def __revoke_security_group_cb__(self, kwargs, callback):
     try:
         ret = []
         for i in range(len(kwargs['ip_protocol'])):
             ret.append(self.clc.revoke_security_group(kwargs['name'],
                 kwargs['src_security_group_name'][i] if kwargs['src_security_group_name'] else None,
                 kwargs['src_security_group_owner_id'][i] if kwargs['src_security_group_owner_id'] else None,
                 kwargs['ip_protocol'][i], kwargs['from_port'][i], kwargs['to_port'][i],
                 kwargs['cidr_ip'][i] if kwargs['cidr_ip'] else None, kwargs['group_id'][i] if kwargs['group_id'] else None,
                 kwargs['src_security_group_group_id'][i] if kwargs['src_security_group_group_id'] else None))
         Threads.instance().invokeCallback(callback, Response(data=ret))
     except Exception as ex:
         Threads.instance().invokeCallback(callback, Response(error=ex))
示例#56
0
 def __run_instances_cb__(self, kwargs, callback):
     try:
         ret = self.clc.run_instances(kwargs['image_id'], kwargs['min_count'], kwargs['max_count'],
                   kwargs['key_name'], kwargs['security_groups'],
                   kwargs['user_data'], kwargs['addressing_type'],
                   kwargs['instance_type'], kwargs['placement'],
                   kwargs['kernel_id'], kwargs['ramdisk_id'],
                   kwargs['monitoring_enabled'], kwargs['subnet_id'],
                   kwargs['block_device_map'],
                   kwargs['disable_api_termination'],
                   kwargs['instance_initiated_shutdown_behavior'],
                   kwargs['private_ip_address'],
                   kwargs['placement_group'], kwargs['client_token'],
                   kwargs['security_group_ids'],
                   kwargs['additional_info'], kwargs['instance_profile_name'],
                   kwargs['instance_profile_arn'], kwargs['tenancy'])
         Threads.instance().invokeCallback(callback,
                         Response(data=self.__normalize_instances__([ret])))
     except Exception as ex:
         Threads.instance().invokeCallback(callback, Response(error=ex))
示例#57
0
 def handleGetPassword(self, clc, callback):
     instanceid = self.get_argument("InstanceId")
     Threads.instance().runThread(self.__get_password_cb__, ({"instanceid": instanceid}, callback))
 def deregister_instances(self, load_balancer_name, instances, callback=None):
     params = {'load_balancer_name':load_balancer_name, 'instances':instances}
     Threads.instance().runThread(self.__deregister_instances_cb__, (params, callback))
 def __get_all_load_balancers_cb__(self, kwargs, callback):
     try:
         self.caches['balancers'].values = self.bal.get_all_load_balancers(kwargs['load_balancer_names'])
         Threads.instance().invokeCallback(callback, Response(data=self.caches['balancers'].values))
     except Exception as ex:
         Threads.instance().invokeCallback(callback, Response(error=ex))