Ejemplo n.º 1
0
    def take_action(self, parsed_args):
        network_client = self.app.client_manager.network

        body = {'firewall_interface': {}}
        firewall_interface_id = parsed_args.firewall_interface_id
        utils.update_dict(
            parsed_args, body['firewall_interface'],
            ['description', 'network_id', 'ip_address', 'virtual_ip_address'])

        dic = network_client.update_firewall_interface(
            firewall_interface_id, body).get('firewall_interface')
        columns = utils.get_columns(dic)
        obj = to_obj.FirewallInterface(dic)
        data = utils.get_item_properties(
            obj,
            columns,
        )
        return (columns, data)
Ejemplo n.º 2
0
    def take_action(self, parsed_args):
        dh_client = self.app.client_manager.dh

        self.log.debug('server-id: %s', parsed_args.server_id)

        rows = [
            'ID', 'Name', 'Status', 'Description', 'Hypervisor Type',
            'imageRef', 'Baremetal Server'
        ]

        row_headers = rows

        mixed_case_fields = ['imageRef']

        data = dh_client.servers.get(server_id=parsed_args.server_id)

        return (row_headers, (utils.get_item_properties(
            data, rows, mixed_case_fields=mixed_case_fields)))
Ejemplo n.º 3
0
    def take_action(self, parsed_args):
        bare_client = self.app.client_manager.bare
        identity_client = self.app.client_manager.identity

        if parsed_args.public_key:
            columns = (
                'Name',
                'Public key',
            )

            data = bare_client.keypairs.create(parsed_args.keypair,
                                               parsed_args.public_key)

        else:
            columns = ('Name', )
            data = bare_client.keypairs.create(parsed_args.keypair)

        return (columns, utils.get_item_properties(data, columns))
Ejemplo n.º 4
0
    def take_action(self, parsed_args):
        sss_client = self.app.client_manager.sss

        body = {}
        if parsed_args.login_id is not None:
            body['login_id'] = str(parsed_args.login_id)
        if parsed_args.mail_address is not None:
            body['mail_address'] = str(parsed_args.mail_address)
        if parsed_args.notify_password is not None:
            body['notify_password'] = parsed_args.notify_password
        if parsed_args.password is not None:
            body['password'] = str(parsed_args.password)

        user = sss_client.create_user(body)
        columns = utils.get_columns(user)
        obj = objectify(user)
        data = utils.get_item_properties(obj, columns)
        return columns, data
Ejemplo n.º 5
0
    def take_action(self, parsed_args):
        sss_client = self.app.client_manager.sss

        body = {}
        if parsed_args.tenant_name is not None:
            body['tenant_name'] = str(parsed_args.tenant_name)
        if parsed_args.description is not None:
            body['description'] = str(parsed_args.description)
        if parsed_args.region is not None:
            body['region'] = str(parsed_args.region)
        if parsed_args.contract_id is not None:
            body['contract_id'] = str(parsed_args.contract_id)

        tenant = sss_client.create_tenant(body)
        columns = utils.get_columns(tenant)
        obj = objectify(tenant)
        data = utils.get_item_properties(obj, columns)
        return columns, data
Ejemplo n.º 6
0
    def take_action(self, parsed_args):
        security_order_client = self.app.eclsdk.conn.security_order

        kwargs = {
            'hostname': parsed_args.hostname,
            'locale': parsed_args.locale,
        }

        columns = [
            'code',
            'message',
            'soId',
            'status',
        ]

        status = security_order_client.delete_device(**kwargs)

        return (columns, utils.get_item_properties(status, columns))
Ejemplo n.º 7
0
    def take_action(self, parsed_args):
        network_client = self.app.client_manager.network

        body = {'colocation_logical_link': {}}
        utils.update_dict(parsed_args, body['colocation_logical_link'], [
            'name', 'description', 'colocation_physical_link_id', 'network_id',
            'vlan_id', 'tags'
        ])

        dic = network_client.create_colo_logical_link(body).get(
            'colocation_logical_link')
        columns = utils.get_columns(dic)
        obj = to_obj.ColoLogicalLink(dic)
        data = utils.get_item_properties(
            obj,
            columns,
        )
        return columns, data
Ejemplo n.º 8
0
    def take_action(self, parsed_args):
        security_order_client = self.app.eclsdk.conn.security_order

        kwargs = {
            'soid': parsed_args.soId,
            'locale': parsed_args.locale,
        }

        columns = [
            'code',
            'message',
            'progress_rate',
            'status',
        ]

        status = security_order_client.get_device_order_status(**kwargs)

        return (columns, utils.get_item_properties(status, columns))
Ejemplo n.º 9
0
    def take_action(self, parsed_args):
        sss_client = self.app.client_manager.sss

        columns = (
        )
        column_headers = (
        )

        channel_id = parsed_args.channel_id
        data = [
            objectify(contract) for contract
            in sss_client.list_contracts(channel_id).get('contracts')
        ]

        return (column_headers,
                (utils.get_item_properties(
                    s, columns,
                ) for s in data))
Ejemplo n.º 10
0
    def take_action(self, parsed_args):
        security_order_client = self.app.eclsdk.conn.security_order

        kwargs = {
            'mailaddress': parsed_args.mailaddress,
            'locale': parsed_args.locale,
        }

        columns = [
            'code',
            'message',
            'soId',
            'status',
        ]

        status = security_order_client.cancel_hbs(**kwargs)

        return (columns, utils.get_item_properties(status, columns))
Ejemplo n.º 11
0
    def take_action(self, parsed_args):
        network_client = self.app.client_manager.network

        body = {'public_ip': {}}
        public_ip_id = parsed_args.public_ip_id
        utils.update_dict(parsed_args, body['public_ip'], [
            'description',
        ])

        dic = network_client.update_public_ip(public_ip_id,
                                              body).get('public_ip')
        columns = utils.get_columns(dic)
        obj = to_obj.PubicIP(dic)
        data = utils.get_item_properties(
            obj,
            columns,
        )
        return columns, data
Ejemplo n.º 12
0
    def take_action(self, parsed_args):
        identity_client = self.app.client_manager.identity
        if parsed_args.long:
            columns = ('ID', 'Region', 'Service Name', 'Service Type',
                       'PublicURL', 'AdminURL', 'InternalURL')
        else:
            columns = ('ID', 'Region', 'Service Name', 'Service Type')
        data = identity_client.endpoints.list()

        for ep in data:
            service = common.find_service(identity_client, ep.service_id)
            ep.service_name = service.name
            ep.service_type = service.type
        return (columns,
                (utils.get_item_properties(
                    s, columns,
                    formatters={},
                ) for s in data))
Ejemplo n.º 13
0
    def take_action(self, parsed_args):
        network_client = self.app.client_manager.network

        loadbalancer_id = parsed_args.loadbalancer_id

        body = {}
        body.update({"type": parsed_args.type})

        network_client.reboot_loadbalancer(loadbalancer_id, body=body)
        dic = network_client.show_loadbalancer(loadbalancer_id).get(
            'load_balancer')
        columns = utils.get_columns(dic)
        obj = to_obj.LoadBalancer(dic)
        data = utils.get_item_properties(
            obj,
            columns,
        )
        return columns, data
Ejemplo n.º 14
0
    def take_action(self, parsed_args):
        network_client = self.app.client_manager.network

        body = {'load_balancer': {}}
        loadbalancer_id = parsed_args.loadbalancer_id
        utils.update_dict(parsed_args, body['load_balancer'], [
            'name', 'description', 'load_balancer_plan_id', 'default_gateway'
        ])

        dic = network_client.update_loadbalancer(loadbalancer_id,
                                                 body).get('load_balancer')
        columns = utils.get_columns(dic)
        obj = to_obj.LoadBalancer(dic)
        data = utils.get_item_properties(
            obj,
            columns,
        )
        return columns, data
Ejemplo n.º 15
0
    def take_action(self, parsed_args):
        q = monitoring_utils._make_query(parsed_args)
        monitoring_client = self.app.client_manager.monitoring

        data = monitoring_client.alarms.list_history(q, parsed_args.page, parsed_args.per_page)

        columns = (
            "alarm_id",
            "user_id",
            "project_id",
            "type",
            "detail",
            "timestamp",
            "on_behalf_of",
        )
        return (columns,
                (utils.get_item_properties(
                    s, columns) for s in data))
Ejemplo n.º 16
0
 def take_action(self, parsed_args):
     client = self.app.eclsdk.conn.database
     columns = [
         'ID',
         'Name',
         'Datastore',
         'Volume',
         'Backup Retention Period',
         'Restorable Time',
         'Backup Window',
         'Status',
     ]
     column_headers = copy.deepcopy(columns)
     data = client.instances()
     return (column_headers,
         (utils.get_item_properties(d, columns, formatters={
             'Datastore': utils.format_dict,
             'Volume': utils.format_dict}) for d in data))
Ejemplo n.º 17
0
    def take_action(self, parsed_args):
        network_client = self.app.client_manager.network

        columns = (
            'id',
            'name',
            'firewall_id',
            'ip_address',
            'status',
        )
        column_headers = (
            'ID',
            'Name',
            'Firewall',
            'Address',
            'Status',
        )
        search_opts = {}
        if parsed_args.firewall_id:
            search_opts.update({"firewall_id": parsed_args.firewall_id})
        if parsed_args.id:
            search_opts.update({"id": parsed_args.id})
        if parsed_args.ip_address:
            search_opts.update({"ip_address": parsed_args.ip_address})
        if parsed_args.name:
            search_opts.update({"name": parsed_args.name})
        if parsed_args.network_id:
            search_opts.update({"network_id": parsed_args.network_id})
        if parsed_args.slot_number:
            search_opts.update({"slot_number": parsed_args.slot_number})
        if parsed_args.status:
            search_opts.update({"status": parsed_args.status})
        if parsed_args.virtual_ip_address:
            search_opts.update({"virtual_ip_address": parsed_args.virtual_ip_address})

        data = [to_obj.FirewallInterface(firewall_interface)
                for firewall_interface in
                network_client.list_firewall_interfaces(
                        **search_opts).get('firewall_interfaces')]

        return (column_headers,
                (utils.get_item_properties(
                    s, columns,
                ) for s in data))
Ejemplo n.º 18
0
    def take_action(self, parsed_args):
        network_client = self.app.client_manager.network

        body = {'port': {}}
        body['port'].update({'network_id': parsed_args.network_id})
        if parsed_args.name:
            body['port'].update({'name': parsed_args.name})
        if parsed_args.description:
            body['port'].update({'description': parsed_args.description})
        if not (parsed_args.admin_state_up is None):
            body['port'].update({'admin_state_up': parsed_args.admin_state_up})
        if parsed_args.fixed_ips:
            result = filter(lambda fixed_ip: fixed_ip != {},
                            parsed_args.fixed_ips)
            body['port'].update({'fixed_ips': result})
        if parsed_args.allowed_address_pairs:
            body['port'].update(
                {'allowed_address_pairs': parsed_args.allowed_address_pairs})
        if parsed_args.mac_address:
            body['port'].update({'mac_address': parsed_args.mac_address})
        if parsed_args.segmentation_id:
            body['port'].update(
                {'segmentation_id': parsed_args.segmentation_id})
        if parsed_args.segmentation_type:
            body['port'].update(
                {'segmentation_type': parsed_args.segmentation_type})
        if parsed_args.device_id:
            body['port'].update({'device_id': parsed_args.device_id})
        if parsed_args.device_owner:
            body['port'].update({'device_owner': parsed_args.device_owner})
        if parsed_args.tags:
            tags = {}
            for tag in parsed_args.tags:
                tags.update(tag)
            body['port'].update({'tags': tags})

        dic = network_client.create_port(body).get('port')
        columns = utils.get_columns(dic)
        obj = to_obj.Port(dic)
        data = utils.get_item_properties(
            obj,
            columns,
        )
        return (columns, data)
Ejemplo n.º 19
0
def _show_stack(heat_client, stack_id, format='', short=False):
    try:
        data = heat_client.stacks.get(stack_id=stack_id)
    except heat_exc.HTTPNotFound:
        raise exc.CommandError('Stack not found: %s' % stack_id)
    else:

        columns = [
            'id',
            'stack_name',
            'description',
            'creation_time',
            # 'updated_time',
            'stack_status',
            'stack_status_reason',
        ]

        if not short:
            columns += [
                'parameters',
                'outputs',
                'links',
            ]

            exclude_columns = ('template_description',)
            for key in data.to_dict():
                # add remaining columns without an explicit order
                if key not in columns and key not in exclude_columns:
                    columns.append(key)

        formatters = {}
        complex_formatter = None
        if format in 'table':
            complex_formatter = heat_utils.yaml_formatter
        elif format in ('shell', 'value', 'html'):
            complex_formatter = heat_utils.json_formatter
        if complex_formatter:
            formatters['parameters'] = complex_formatter
            formatters['outputs'] = complex_formatter
            formatters['links'] = complex_formatter
            formatters['tags'] = complex_formatter

        return columns, utils.get_item_properties(data, columns,
                                                  formatters=formatters)
Ejemplo n.º 20
0
    def take_action(self, parsed_args):
        dh_client = self.app.client_manager.dh
        self.log.debug('license type: %s',parsed_args.license_type)

        rows = [
            "ID",
            "Key",
            "Assigned From",
            "Expires At",
            "License Type"
        ]
        row_headers = rows

        data = dh_client.licenses.create(license_type=parsed_args.license_type)

        return (row_headers,
                utils.get_item_properties(
                    data, rows
                    ))
Ejemplo n.º 21
0
    def take_action(self, parsed_args):
        bare_client = self.app.client_manager.bare
        identity_client = self.app.client_manager.identity

        data = bare_client.availability_zones.list()
        columns = (
            'zoneName',
            'zoneState',
            'hosts',
           )
        mixed_case_fields = ['zoneState','zoneName']
        return (columns,
                (utils.get_item_properties(
                    s, columns,
                    mixed_case_fields=mixed_case_fields,
                    formatters={
                        'zoneState': bare_utils._format_show_dicts_list
                    },
                ) for s in data))
Ejemplo n.º 22
0
    def take_action(self, parsed_args):
        network_client = self.app.client_manager.network

        body = {'interdc_interface': {}}
        utils.update_dict(parsed_args, body['interdc_interface'], [
            'name', 'description', 'netmask', 'vrid', 'interdc_gw_id',
            'primary_ipv4', 'secondary_ipv4', 'gw_vipv4', 'primary_ipv6',
            'secondary_ipv6', 'gw_vipv6'
        ])

        dic = network_client.create_interdc_interface(body).get(
            'interdc_interface')
        columns = utils.get_columns(dic)
        obj = to_obj.InterDCInterface(dic)
        data = utils.get_item_properties(
            obj,
            columns,
        )
        return columns, data
Ejemplo n.º 23
0
    def take_action(self, parsed_args):
        client = self.app.eclsdk.conn.rca

        columns = (
            'status',
            'id',
            'links'
        )
        column_headers = (
            'Status',
            'ID',
            'Links'
        )

        data = client.versions()
        return (column_headers,
                (utils.get_item_properties(
                    s, columns, formatters={'links': utils.format_list_of_dicts}
                ) for s in data))
Ejemplo n.º 24
0
    def take_action(self, parsed_args):
        client = self.app.eclsdk.conn.provider_connectivity

        columns = [
            'ID',
            'Name',
            'Name Other',
            'Tenant ID',
            'Network ID',
            'Status',
        ]
        column_headers = copy.deepcopy(columns)

        data = client.tenant_connection_requests()

        return (column_headers, (utils.get_item_properties(
            s,
            columns,
        ) for s in data))
Ejemplo n.º 25
0
Archivo: waf.py Proyecto: nttcom/eclcli
    def take_action(self, parsed_args):
        security_order_client = self.app.eclsdk.conn.security_order

        kwargs = {
            'licensekind': parsed_args.licensekind,
            'azgroup': parsed_args.azgroup,
            'locale': parsed_args.locale,
        }

        columns = [
            'code',
            'message',
            'soId',
            'status',
        ]

        status = security_order_client.create_waf(**kwargs)

        return (columns, utils.get_item_properties(status, columns))
Ejemplo n.º 26
0
    def take_action(self, parsed_args):
        bare_client = self.app.client_manager.bare
        identity_client = self.app.client_manager.identity

        search_opts = {}
        self.log.debug('search options: %s', search_opts)

        columns = (
            'ID',
            'Mac Addr',
            'Network Physical Port ID',
            'Plane',
            'Hardware ID',
        )

        server_obj = utils.find_resource(bare_client.servers,
                                         parsed_args.server)
        data = bare_client.ports.list(server_obj.id)
        return (columns, (utils.get_item_properties(s, columns) for s in data))
Ejemplo n.º 27
0
    def take_action(self, parsed_args):
        client = self.app.eclsdk.conn.virtual_network_appliance

        columns = [
            'ID',
            'Name',
            'Enabled',
            'Number of Interfaces',
            'Max Number of AAP',
        ]
        column_headers = copy.deepcopy(columns)

        data = client.virtual_network_appliance_plans()

        return (column_headers,
                (utils.get_item_properties(
                    s, columns,
                    formatters={'Metadata': utils.format_dict},
                ) for s in data))
Ejemplo n.º 28
0
    def take_action(self, parsed_args):
        network_client = self.app.client_manager.network

        body = {}
        internet_gateway_id = parsed_args.internet_gateway_id
        if parsed_args.name is not None:
            body['name'] = str(parsed_args.name)
        if parsed_args.description is not None:
            body['description'] = str(parsed_args.description)
        if parsed_args.qos_option_id is not None:
            body['qos_option_id'] = parsed_args.qos_option_id

        dic = network_client.update_internet_gateway(
            internet_gateway_id, body={'internet_gateway': body}).get('internet_gateway')
        columns = utils.get_columns(dic)
        obj = to_obj.InternetGateway(dic)
        data = utils.get_item_properties(
            obj, columns,)
        return columns, data
Ejemplo n.º 29
0
    def take_action(self, parsed_args):
        bare_client = self.app.client_manager.bare
        identity_client = self.app.client_manager.identity

        columns = (
            'ID',
            'Status',
            'Links',
        )

        data = bare_client.versions.get(parsed_args.version)
        return (columns,utils.get_item_properties(
            data,
            columns,
            mixed_case_fields = [],
            formatters = {
                'Links': bare_utils._format_links
            }
        ))
Ejemplo n.º 30
0
    def take_action(self, parsed_args):
        network_client = self.app.client_manager.network

        columns = (
            'id',
            'name',
            'status',
        )
        column_headers = (
            'ID',
            'Name',
            'Status',
        )

        search_opts = dict()
        if parsed_args.admin_username:
            search_opts.update({"admin_username": parsed_args.admin_username})
        if parsed_args.user_username:
            search_opts.update({"user_username": parsed_args.user_username})
        if parsed_args.default_gateway:
            search_opts.update(
                {"default_gateway": parsed_args.default_gateway})
        if parsed_args.firewall_plan_id:
            search_opts.update(
                {"firewall_plan_id": parsed_args.firewall_plan_id})
        if parsed_args.id:
            search_opts.update({"id": parsed_args.id})
        if parsed_args.name:
            search_opts.update({"name": parsed_args.name})
        if parsed_args.status:
            search_opts.update({"status": parsed_args.status})

        data = [
            to_obj.Firewall(firewall)
            for firewall in network_client.list_firewalls(
                **search_opts).get('firewalls')
        ]

        return (column_headers, (utils.get_item_properties(
            s,
            columns,
        ) for s in data))