def _validate_keypairs(self): errors = [] if not os.path.exists(os.path.expanduser(self.PEM)): errors.append(' ERROR: pem file is not present: ' + self.PEM) keys = [k.name for k in util.get_conn().get_all_key_pairs()] if self.KEY_NAME not in keys: errors.append(' ERROR: aws keypair not found: ' + self.KEY_NAME) return errors
def __init__( self, conn=None, service_root=None, ): """""" self.conn = conn or util.get_conn() self._ymir_service_root = service_root
def ymir_shell(args): """ """ service = yapi.load_service_from_json() report("starting shell") user_ns = dict(conn=util.get_conn(), service=service) report("namespace: \n\n{0}\n\n".format(user_ns)) try: from smashlib import embed except ImportError: raise SystemExit("need smashlib should be installed first") embed(user_ns=user_ns, )
def ymir_shell(args): """ """ service = yapi.load_service_from_json() report("starting shell") user_ns = dict( conn=util.get_conn(), service=service) report("namespace: \n\n{0}\n\n".format(user_ns)) try: from smashlib import embed except ImportError: raise SystemExit("need smashlib should be installed first") embed(user_ns=user_ns,)
def sg_sync(name=None, description=None, rules=[], vpc=None, conn=None): """ http://boto.readthedocs.org/en/latest/security_groups.html """ logger.debug("Synchronizing security group: {0} -- {1}".format( name, description)) assert rules and name conn = conn or get_conn() description = description or name csg_kargs = {} if vpc is not None: conn = boto.vpc.connect_to_region('us-east-1') csg_kargs['vpc_id'] = vpc sg = get_or_create_security_group(conn, name, description) current_rules = sg_rules(sg) rules = set([tuple(map(str, r)) for r in rules]) new_rules = rules - current_rules stale_rules = current_rules - rules if not stale_rules and not new_rules: print colors.blue("rules already synchronized:") + \ " nothing to do." if stale_rules: print colors.blue("stale rules: ") + \ "{0} total".format(len(stale_rules)) if new_rules: print colors.blue("new rules: ") + \ "{0} total".format(len(new_rules)) for rule in new_rules: print colors.blue('authorizing') + ' new rule: {0}'.format(rule), catch_ec2_error(lambda rule=rule: sg.authorize(*rule)) for rule in stale_rules: print colors.red('revoking:') + \ ' old rule: {0}'.format(rule) catch_ec2_error(lambda rule=rule: sg.revoke(*rule))
def __init__(self, conn=None, service_root=None, ): """""" self.conn = conn or util.get_conn() self._ymir_service_root = service_root