コード例 #1
0
    def execute(self, server, cmd_data_json):
        if ("parent_name" not in cmd_data_json
                or "vlan_id" not in cmd_data_json):
            return self._CREATE_FAIL_RESPONSE(
                'create vlan request must have parent name' +
                ' and vlan id defined, got: ' + str(cmd_data_json))

        parent = cmd_data_json["parent_name"]
        vlan_id = cmd_data_json["vlan_id"]
        cmd = "net-vlan-create"

        call = NaElement(cmd)

        vi = NaElement("vlan-info")
        vi.child_add_string("parent-interface", parent)
        vi.child_add_string("vlanid", vlan_id)
        if "node_name" in cmd_data_json:
            vi.child_add_string("node", cmd_data_json["node_name"])
        call.child_add(vi)

        _, err_resp = self._INVOKE_CHECK(server, call,
                                         cmd + ": " + parent + ":" + vlan_id)
        if err_resp:
            return err_resp

        return self._CREATE_EMPTY_RESPONSE(True, "")
コード例 #2
0
    def execute(self, server, cmd_data_json):
        if ("name" not in cmd_data_json or "ipspace" not in cmd_data_json
                or "ip_ranges" not in cmd_data_json):
            return self._CREATE_FAIL_RESPONSE(
                "subnet ip range " + self._get_cmd_type() + " commands must" +
                " have name, ipspace and ip_ranges defined" + ", got: " +
                str(cmd_data_json))

        name = cmd_data_json["name"]
        ipspace = cmd_data_json["ipspace"]
        iprs = cmd_data_json["ip_ranges"]
        cmd = ("net-subnet-" + self._get_cmd_type() + "-ranges")

        call = NaElement(cmd)

        call.child_add_string("subnet-name", name)
        call.child_add_string("ipspace", ipspace)

        el_iprs = NaElement("ip-ranges")

        for ip_range in iprs:
            el_iprs.child_add_string("ip-range", ip_range)

        call.child_add(el_iprs)

        _, err_resp = self._INVOKE_CHECK(
            server, call, cmd + ": " + name + " [" + ipspace + "]" +
            self._get_cmd_type() + str(iprs))
        if err_resp:
            return err_resp

        # LOGGER.debug(resp.sprintf())

        return self._CREATE_EMPTY_RESPONSE(True, "")
コード例 #3
0
    def create(self, cluster):
        api_call = NaElement('net-interface-create')
        api_child_data_protocols = NaElement('data-protocols')
        api_child_data_protocols.child_add_string('data-protocol',
                                                  self.data_protocol)
        api_call.child_add(api_child_data_protocols)

        api_call.child_add_string('vserver', self.vserver)

        if (self.data_protocol == 'none') or (self.data_protocol == 'nfs') or (
                self.data_protocol == 'cifs') or (self.data_protocol
                                                  == 'iscsi'):
            api_call.child_add_string('interface-name', self.interface_name)
            api_call.child_add_string('role', self.role)
            api_call.child_add_string('home-node', self.home_node)
            api_call.child_add_string('home-port', self.home_port)
            api_call.child_add_string('address', self.address)
            api_call.child_add_string('netmask', self.netmask)
        elif (self.data_protocol == 'fcp'):
            api_call.child_add_string('interface-name', self.interface_name)
            api_call.child_add_string('role', self.role)
            api_call.child_add_string('home-node', self.home_node)
            api_call.child_add_string('home-port', self.home_port)

        output = cluster.run_command(api_call)
        return output.results_status(), output.sprintf()
コード例 #4
0
    def execute(self, server, cmd_data_json):
        if ("parent_name" not in cmd_data_json
                or "vlan_id" not in cmd_data_json):
            return self._CREATE_FAIL_RESPONSE(
                'get vlan request must have parent name' +
                ' and vlan id defined, got: ' + str(cmd_data_json))

        parent = cmd_data_json["parent_name"]
        vlan_id = cmd_data_json["vlan_id"]
        cmd = "net-vlan-get-iter"

        call = NaElement(cmd)

        qe = NaElement("query")
        qe_vi = NaElement("vlan-info")
        qe_vi.child_add_string("parent-interface", parent)
        qe_vi.child_add_string("vlanid", vlan_id)
        if "node_name" in cmd_data_json:
            qe_vi.child_add_string("node", cmd_data_json["node_name"])
        qe.child_add(qe_vi)
        call.child_add(qe)

        des_attr = NaElement("desired-attributes")
        vi = NaElement("vlan-info")
        vi.child_add_string("interface-name", "<interface-name>")
        vi.child_add_string("node", "<node>")
        vi.child_add_string("parent-interface", "<parent-interface>")
        vi.child_add_string("vlanid", "<vlanid>")
        des_attr.child_add(vi)
        call.child_add(des_attr)

        resp, err_resp = self._INVOKE_CHECK(
            server, call, cmd + ": " + parent + ":" + vlan_id)
        if err_resp:
            return err_resp

        #LOGGER.debug(resp.sprintf())

        vlan_cnt = self._GET_INT(resp, 'num-records')
        if not vlan_cnt or vlan_cnt < 1:
            # either None or 0 evaluates to False
            return self._CREATE_FAIL_RESPONSE(
                'no vlans or too many found for query: [' +
                str(cmd_data_json) + '] result is: ' + resp.sprintf())

        if not resp.child_get("attributes-list"):
            return self._CREATE_FAIL_RESPONSE('no vlan data found in: ' +
                                              resp.sprintf())

        vlan_info = resp.child_get("attributes-list").children_get()[0]

        dd = {
            "name": self._GET_STRING(vlan_info, "interface-name"),
            "node_name": self._GET_STRING(vlan_info, "node"),
            "parent_name": self._GET_STRING(vlan_info, "parent-interface"),
            "vlan_id": self._GET_STRING(vlan_info, "vlanid")
        }

        return {'success': True, 'errmsg': '', 'data': dd}
コード例 #5
0
    def create(self, cluster):
        api_call = NaElement('aggr-create')
        api_call.child_add_string('aggregate', self.aggr_name)
        api_call.child_add_string('disk-count', self.disk_count)
        api_call.child_add_string('disk-type', self.disk_type)
        api_call.child_add_string('raid-type', self.raid_type)
        api_call.child_add_string('raid-size', self.raid_size)

        api_child_nodes = NaElement('nodes')
        api_child_nodes.child_add_string('node-name', self.node_name)

        api_call.child_add(api_child_nodes)

        output = cluster.run_command(api_call)
        return output.results_status(), output.sprintf()
コード例 #6
0
    def set_properties(self, cluster):
        api_call = NaElement('vserver-modify')
        api_call.child_add_string('vserver-name', self.vserver_name)

        api_child_aggrs = NaElement('aggr-list')
        for aggr in self.aggr_list:
            api_child_aggrs.child_add_string('aggr-name', aggr)

        api_child_protocols = NaElement('allowed-protocols')
        for protocol in self.allowed_protocols:
            api_child_protocols.child_add_string('protocol', protocol)

        api_call.child_add(api_child_aggrs)
        api_call.child_add(api_child_protocols)

        output = cluster.run_command(api_call)
        return output.results_status(), output.sprintf()
コード例 #7
0
    def execute(self, server, cmd_data_json):
        if "name" not in cmd_data_json:
            return self._CREATE_FAIL_RESPONSE(
                "broadcast domain status commands must" +
                " have name defined, got: " + str(cmd_data_json))

        name = cmd_data_json["name"]
        cmd = "net-port-broadcast-domain-get-iter"

        call = NaElement(cmd)

        qe = NaElement("query")
        qe_bcdi = NaElement("net-port-broadcast-domain-info")
        qe_bcdi.child_add_string("broadcast-domain", name)
        qe.child_add(qe_bcdi)
        call.child_add(qe)

        dattr = NaElement("desired-attributes")
        bcdi = NaElement("net-port-broadcast-domain-info")
        bcdi.child_add_string("port-update-status-combined",
                              "<port-update-status-combined>")
        dattr.child_add(bcdi)

        call.child_add(dattr)

        resp, err_resp = self._INVOKE_CHECK(server, call, cmd + ": " + name)
        if err_resp:
            return err_resp

        # LOGGER.debug(resp.sprintf())

        bcd_cnt = self._GET_INT(resp, 'num-records')
        if bcd_cnt != 1:
            # too many bc domains found for query
            return self._CREATE_FAIL_RESPONSE(
                'too many broadcast domains found for' + ' query: [' +
                str(cmd_data_json) + '] result is: ' + resp.sprintf())

        if not resp.child_get("attributes-list"):
            return self._CREATE_FAIL_RESPONSE(
                'no broadcast domain info data found in: ' + resp.sprintf())

        bcd_info = resp.child_get("attributes-list").children_get()[0]

        dd = {
            "update_status":
            self._GET_STRING(bcd_info, "port-update-status-combined"),
        }

        return {'success': True, 'errmsg': '', 'data': dd}
コード例 #8
0
    def execute(self, server, cmd_data_json):
        if ("name" not in cmd_data_json or "ipspace" not in cmd_data_json
                or "ports" not in cmd_data_json):
            return self._CREATE_FAIL_RESPONSE(
                "broadcast domain port " + self._get_cmd_type() +
                " commands must" + " have name, ipspace and ports defined" +
                ", got: " + str(cmd_data_json))

        name = cmd_data_json["name"]
        ipspace = cmd_data_json["ipspace"]
        ports = cmd_data_json["ports"]
        cmd = ("net-port-broadcast-domain-" + self._get_cmd_type() + "-ports")

        call = NaElement(cmd)

        call.child_add_string("broadcast-domain", name)
        call.child_add_string("ipspace", ipspace)

        ports_el = NaElement("ports")

        for port_name in ports:
            ports_el.child_add_string("net-qualified-port-name", port_name)

        call.child_add(ports_el)

        resp, err_resp = self._INVOKE_CHECK(
            server, call, cmd + ": " + name + " [" + ipspace + "]" +
            self._get_cmd_type() + str(ports))
        if err_resp:
            return err_resp

        # LOGGER.debug(resp.sprintf())

        dd = {
            "update_status": self._GET_STRING(resp,
                                              "port-update-status-combined"),
        }

        return {'success': True, 'errmsg': '', 'data': dd}
コード例 #9
0
    def execute(self, server, cmd_data_json):
        if ("name" not in cmd_data_json or "mtu" not in cmd_data_json):
            return self._CREATE_FAIL_RESPONSE(
                "broadcast domain create commands must" +
                " have name and mtu defined, got: " + str(cmd_data_json))

        name = cmd_data_json["name"]
        mtu = cmd_data_json["mtu"]
        cmd = "net-port-broadcast-domain-create"

        call = NaElement(cmd)

        call.child_add_string("broadcast-domain", name)
        call.child_add_string("mtu", mtu)

        if "ipspace" in cmd_data_json:
            call.child_add_string("ipspace", cmd_data_json["ipspace"])

        if "ports" in cmd_data_json:
            ports = NaElement("ports")

            for port_name in cmd_data_json["ports"]:
                ports.child_add_string("net-qualified-port-name", port_name)

            call.child_add(ports)

        resp, err_resp = self._INVOKE_CHECK(server, call, cmd + ": " + name)
        if err_resp:
            return err_resp

        # LOGGER.debug(resp.sprintf())

        dd = {
            "update_status": self._GET_STRING(resp,
                                              "port-update-status-combined"),
        }

        return {'success': True, 'errmsg': '', 'data': dd}
コード例 #10
0
    def execute(self, server, cmd_data_json):
        if ("node" not in cmd_data_json or "port" not in cmd_data_json):
            return self._CREATE_FAIL_RESPONSE(
                'find port by pattern request must have' +
                ' node and port defined, got: ' + str(cmd_data_json))

        node = cmd_data_json["node"]
        port = cmd_data_json["port"]
        cmd = "net-port-get-iter"

        call = NaElement(cmd)

        qe = NaElement("query")
        qe_npi = NaElement("net-port-info")
        qe_npi.child_add_string("node", node)
        qe_npi.child_add_string("port", port)
        qe.child_add(qe_npi)
        call.child_add(qe)

        des_attr = NaElement("desired-attributes")
        npi = NaElement("net-port-info")
        npi.child_add_string("port", "<port>")

        des_attr.child_add(npi)
        call.child_add(des_attr)

        resp, err_resp = self._INVOKE_CHECK(server, call,
                                            cmd + ": " + node + ":" + port)
        if err_resp:
            return err_resp

        #LOGGER.debug(resp.sprintf())

        ports = []
        if resp.child_get("attributes-list"):
            for port_info in resp.child_get("attributes-list").children_get():
                ports.append(self._GET_STRING(port_info, "port"))

        return {'success': True, 'errmsg': '', 'data': {'ports': ports}}
コード例 #11
0
    def execute(self, server, cmd_data_json):
        if ("node" not in cmd_data_json or "port" not in cmd_data_json):
            return self._CREATE_FAIL_RESPONSE(
                'get port request must have node and port defined, got: ' +
                str(cmd_data_json))

        node = cmd_data_json["node"]
        port = cmd_data_json["port"]
        cmd = "net-port-get-iter"

        call = NaElement(cmd)

        qe = NaElement("query")
        qe_npi = NaElement("net-port-info")
        qe_npi.child_add_string("node", node)
        qe_npi.child_add_string("port", port)
        qe.child_add(qe_npi)
        call.child_add(qe)

        des_attr = NaElement("desired-attributes")
        npi = NaElement("net-port-info")
        npi.child_add_string("node", "<node>")
        npi.child_add_string("port", "<port>")
        npi.child_add_string("autorevert-delay", "<autorevert-delay>")
        npi.child_add_string("ignore-health-status", "<ignore-health-status>")
        npi.child_add_string("ipspace", "<ipspace>")
        npi.child_add_string("role", "<role>")
        npi.child_add_string("is-administrative-up", "<is-administrative-up>")
        npi.child_add_string("mtu-admin", "<mtu-admin>")
        npi.child_add_string("is-administrative-auto-negotiate",
                             "<is-administrative-auto-negotiate>")
        npi.child_add_string("administrative-speed", "<administrative-speed>")
        npi.child_add_string("administrative-duplex",
                             "<administrative-duplex>")
        npi.child_add_string("administrative-flowcontrol",
                             "<administrative-flowcontrol>")
        npi.child_add_string("link-status", "<link-status>")
        npi.child_add_string("health-status", "<health-status>")
        npi.child_add_string("mac-address", "<mac-address>")
        npi.child_add_string("broadcast-domain", "<broadcast-domain>")
        npi.child_add_string("mtu", "<mtu>")
        npi.child_add_string("is-operational-auto-negotiate",
                             "<is-operational-auto-negotiate>")
        npi.child_add_string("operational-speed", "<operational-speed>")
        npi.child_add_string("operational-duplex", "<operational-duplex>")
        npi.child_add_string("operational-flowcontrol",
                             "<operational-flowcontrol>")
        npi.child_add_string("port-type", "<port-type>")
        npi.child_add_string("vlan-id", "<vlan-id>")
        npi.child_add_string("vlan-node", "<vlan-node>")
        npi.child_add_string("vlan-port", "<vlan-port>")

        des_attr.child_add(npi)
        call.child_add(des_attr)

        resp, err_resp = self._INVOKE_CHECK(server, call,
                                            cmd + ": " + node + ":" + port)
        if err_resp:
            return err_resp

        #LOGGER.debug(resp.sprintf())

        port_cnt = self._GET_INT(resp, 'num-records')
        if port_cnt != 1:
            # too many ports received for query
            return self._CREATE_FAIL_RESPONSE(
                'too many ports found for query: [' + str(cmd_data_json) +
                '] result is: ' + resp.sprintf())

        if not resp.child_get("attributes-list"):
            return self._CREATE_FAIL_RESPONSE('no port data found in: ' +
                                              resp.sprintf())

        port_info = resp.child_get("attributes-list").children_get()[0]

        dd = {
            "node":
            self._GET_STRING(port_info, "node"),
            "port":
            self._GET_STRING(port_info, "port"),
            "auto_rev_delay":
            self._GET_STRING(port_info, "autorevert-delay"),
            "ignr_health":
            self._GET_STRING(port_info, "ignore-health-status"),
            "ipspace":
            self._GET_STRING(port_info, "ipspace"),
            "role":
            self._GET_STRING(port_info, "role"),
            "admin_up":
            self._GET_STRING(port_info, "is-administrative-up"),
            "admin_mtu":
            self._GET_STRING(port_info, "mtu-admin"),
            "admin_auto":
            self._GET_STRING(port_info, "is-administrative-auto-negotiate"),
            "admin_speed":
            self._GET_STRING(port_info, "administrative-speed"),
            "admin_duplex":
            self._GET_STRING(port_info, "administrative-duplex"),
            "admin_flow":
            self._GET_STRING(port_info, "administrative-flowcontrol"),
            "status":
            self._GET_STRING(port_info, "link-status"),
            "health":
            self._GET_STRING(port_info, "health-status"),
            "mac":
            self._GET_STRING(port_info, "mac-address"),
            "broadcast_domain":
            self._GET_STRING(port_info, "broadcast-domain"),
            "mtu":
            self._GET_STRING(port_info, "mtu"),
            "auto":
            self._GET_STRING(port_info, "is-operational-auto-negotiate"),
            "speed":
            self._GET_STRING(port_info, "operational-speed"),
            "duplex":
            self._GET_STRING(port_info, "operational-duplex"),
            "flow":
            self._GET_STRING(port_info, "operational-flowcontrol"),
            "type":
            self._GET_STRING(port_info, "port-type"),
            "vlan_id":
            self._GET_STRING(port_info, "vlan-id"),
            "vlan_node":
            self._GET_STRING(port_info, "vlan-node"),
            "vlan_port":
            self._GET_STRING(port_info, "vlan-port")
        }

        return {'success': True, 'errmsg': '', 'data': dd}
コード例 #12
0
    def execute(self, server, cmd_data_json):
        if ("node" not in cmd_data_json or "name" not in cmd_data_json):
            return self._CREATE_FAIL_RESPONSE(
                'get port group request must have node ' +
                'and name defined, got: ' + str(cmd_data_json))

        node = cmd_data_json["node"]
        name = cmd_data_json["name"]
        cmd = "net-port-ifgrp-get"

        call = NaElement(cmd)

        call.child_add_string("ifgrp-name", name)
        call.child_add_string("node", node)

        des_attr = NaElement("desired-attributes")
        npgi = NaElement("net-ifgrp-info")

        npgi.child_add_string("node", "<node>")
        npgi.child_add_string("ifgrp-name", "<ifgrp-name>")
        npgi.child_add_string("mode", "<mode>")
        npgi.child_add_string("distribution-function",
                              "<distribution-function>")

        npgi.child_add_string("port-participation", "<port-participation>")

        ps = NaElement("ports")
        ps.child_add_string("lif-bindable", "<lif-bindable>")
        npgi.child_add(ps)

        psd = NaElement("down-ports")
        psd.child_add_string("lif-bindable", "<lif-bindable>")
        npgi.child_add(psd)

        psu = NaElement("up-ports")
        psu.child_add_string("lif-bindable", "<lif-bindable>")
        npgi.child_add(psu)

        des_attr.child_add(npgi)
        call.child_add(des_attr)

        resp, err_resp = self._INVOKE_CHECK(server, call,
                                            cmd + ": " + node + ":" + name)
        if err_resp:
            return err_resp

        #LOGGER.debug(resp.sprintf())

        if not resp.child_get("attributes"):
            return self._CREATE_FAIL_RESPONSE('no port group data found in: ' +
                                              resp.sprintf())

        pg_info = resp.child_get("attributes").children_get()[0]

        dd = {
            "node": self._GET_STRING(pg_info, "node"),
            "name": self._GET_STRING(pg_info, "ifgrp-name"),
            "mode": self._GET_STRING(pg_info, "mode"),
            "dist": self._GET_STRING(pg_info, "distribution-function"),
            "part": self._GET_STRING(pg_info, "port-participation"),
            "ports": self._GET_CONTENT_LIST(pg_info, "ports"),
            "ports_down": self._GET_CONTENT_LIST(pg_info, "down-ports"),
            "ports_up": self._GET_CONTENT_LIST(pg_info, "up-ports")
        }

        return {'success': True, 'errmsg': '', 'data': dd}
コード例 #13
0
    def execute(self, server, cmd_data_json):
        if ("name" not in cmd_data_json and "uuid" not in cmd_data_json):
            return self._CREATE_FAIL_RESPONSE(
                'get aggr request must have either ' +
                'name or uuid defined, got: ' + str(cmd_data_json))

        cmd = "aggr-get-iter"

        call = NaElement(cmd)

        qe = NaElement("query")
        qi_aa = NaElement("aggr-attributes")

        for key in ["name", "uuid"]:
            if key in cmd_data_json:
                qi_aa.child_add_string("aggregate-" + key, cmd_data_json[key])

        if "nodes" in cmd_data_json:
            qi_nodes = NaElement("nodes")

            for node_name in cmd_data_json["nodes"]:
                qi_nodes.child_add_string("node-name", node_name)

            qi_aa.child_add(qi_nodes)

        qe.child_add(qi_aa)
        call.child_add(qe)

        des_attr = NaElement("desired-attributes")

        agg_attr = NaElement("aggr-attributes")
        agg_attr.child_add_string("aggregate-name", "<aggregate-name>")
        agg_attr.child_add_string("aggregate-uuid", "<aggregate-uuid>")

        agg_spc = NaElement("aggr-space-attributes")
        agg_spc.child_add_string("percent-used-capacity",
                                 "<percent-used-capacity>")
        agg_spc.child_add_string("physical-used-percent",
                                 "<physical-used-percent>")
        agg_spc.child_add_string("size-available", "<size-available>")
        agg_spc.child_add_string("size-total", "<size-total>")
        agg_spc.child_add_string("size-used", "<size-used>")
        agg_spc.child_add_string("total-reserved-space",
                                 "<total-reserved-space>")
        agg_attr.child_add(agg_spc)

        agg_vcnt = NaElement("aggr-volume-count-attributes")
        agg_vcnt.child_add_string("flexvol-count", "<flexvol-count>")
        agg_attr.child_add(agg_vcnt)

        des_attr.child_add(agg_attr)
        call.child_add(des_attr)

        resp, err_resp = self._INVOKE_CHECK(
            server, call, cmd + ": <-- " + str(cmd_data_json))
        if err_resp:
            return err_resp

        agg_cnt = self._GET_INT(resp, 'num-records')
        if agg_cnt != 1:
            # too many aggregates found for query
            return self._CREATE_FAIL_RESPONSE('too many aggregates found for' +
                                              ' query: [' +
                                              str(cmd_data_json) +
                                              '] result is: ' + resp.sprintf())

        if not resp.child_get("attributes-list"):
            return self._CREATE_FAIL_RESPONSE(
                'no aggregate info data found in: ' + resp.sprintf())

        agg_info = resp.child_get("attributes-list").children_get()[0]
        dd = {
            "name": self._GET_STRING(agg_info, "aggregate-name"),
            "uuid": self._GET_STRING(agg_info, "aggregate-uuid"),
        }

        agg_si = agg_info.child_get("aggr-space-attributes")
        if agg_si:
            dd["pct_used_cap"] = self._GET_INT(agg_si, "percent-used-capacity")
            dd["pct_used_phys"] = self._GET_INT(agg_si,
                                                "physical-used-percent")
            dd["size_avail"] = self._GET_INT(agg_si, "size-available")
            dd["size_total"] = self._GET_INT(agg_si, "size-total")
            dd["size_used"] = self._GET_INT(agg_si, "size-used")
            dd["size_reserve"] = self._GET_INT(agg_si, "total-reserved-space")

        add_vco = agg_info.child_get("aggr-volume-count-attributes")
        if add_vco:
            dd["flexvol_cnt"] = self._GET_INT(add_vco, "flexvol-count")

        return {'success': True, 'errmsg': '', 'data': dd}
コード例 #14
0
    def execute(self, server, cmd_data_json):
        if ("id" not in cmd_data_json):
            return self._CREATE_FAIL_RESPONSE('get job request must have ' +
                                              'id defined, got: ' +
                                              str(cmd_data_json))

        jid = cmd_data_json['id']

        cmd = "job-get-iter"
        call = NaElement(cmd)

        qe = NaElement("query")

        qi_ji = NaElement("job-info")
        qi_ji.child_add_string("job-id", jid)

        qe.child_add(qi_ji)
        call.child_add(qe)

        des_attr = NaElement("desired-attributes")

        ji = NaElement("job-info")

        ji.child_add_string("job-id", "<job-id>")
        ji.child_add_string("job-vserver", "<job-vserver>")

        ji.child_add_string("job-completion", "<job-completion>")
        ji.child_add_string("job-state", "<job-state>")
        ji.child_add_string("job-status-code", "<job-status-code>")

        des_attr.child_add(ji)
        call.child_add(des_attr)

        resp, err_resp = self._INVOKE_CHECK(
            server, call, cmd + ": <-- " + str(cmd_data_json))

        #LOGGER.debug(resp.sprintf())

        if err_resp:
            return err_resp

        job_cnt = self._GET_INT(resp, 'num-records')
        if job_cnt != 1:
            # too many jobs found for query
            return self._CREATE_FAIL_RESPONSE('too many jobs found for' +
                                              ' query: [' +
                                              str(cmd_data_json) +
                                              '] result is: ' + resp.sprintf())

        if not resp.child_get("attributes-list"):
            return self._CREATE_FAIL_RESPONSE('no job info data found in: ' +
                                              resp.sprintf())

        job_info = resp.child_get("attributes-list").children_get()[0]
        dd = {
            'id': self._GET_INT(job_info, "job-id"),
            'svm': self._GET_STRING(job_info, "job-vserver"),
            'msg': self._GET_STRING(job_info, "job-completion"),
            'status': self._GET_STRING(job_info, "job-state"),
            'errno': self._GET_INT(job_info, "job-status-code")
        }

        return {'success': True, 'errmsg': '', 'data': dd}
コード例 #15
0
    def execute(self, server, cmd_data_json):
        if ("name" not in cmd_data_json or "bc_domain" not in cmd_data_json
                or "ipspace" not in cmd_data_json
                or "subnet" not in cmd_data_json):
            return self._CREATE_FAIL_RESPONSE(
                "subnet create commands must" +
                " have name, broadcast domain, ipspace" +
                " and subnet defined, got: " + str(cmd_data_json))

        name = cmd_data_json["name"]
        bcdom = cmd_data_json["bc_domain"]
        ipspace = cmd_data_json["ipspace"]
        subnet = cmd_data_json["subnet"]
        cmd = "net-subnet-create"

        call = NaElement(cmd)

        call.child_add_string("subnet-name", name)
        call.child_add_string("broadcast-domain", bcdom)
        call.child_add_string("ipspace", ipspace)
        call.child_add_string("subnet", subnet)

        # make sure that create call returns record!
        call.child_add_string("return-record", True)

        if "gateway" in cmd_data_json:
            call.child_add_string("gateway", cmd_data_json["gateway"])

        if "ip_ranges" in cmd_data_json:
            iprs = NaElement("ip-ranges")
            for ip_range in cmd_data_json["ip_ranges"]:
                iprs.child_add_string("ip-range", ip_range)

            call.child_add(iprs)

        resp, err_resp = self._INVOKE_CHECK(server, call, cmd + ": " + name)
        if err_resp:
            return err_resp

        # LOGGER.debug(resp.sprintf())

        if not resp.child_get("result"):
            # no result data in response
            return self._CREATE_FAIL_RESPONSE(
                'no result data for create subnet' + ' with input: [' +
                str(cmd_data_json) + '] result is: ' + resp.sprintf())

        si_info = resp.child_get("result").child_get("net-subnet-info")
        dd = {
            "bc_domain": self._GET_STRING(si_info, "broadcast-domain"),
            "gateway": self._GET_STRING(si_info, "gateway"),
            "ipspace": self._GET_STRING(si_info, "ipspace"),
            "subnet": self._GET_STRING(si_info, "subnet"),
            "name": self._GET_STRING(si_info, "subnet-name"),
            "ip_count": self._GET_INT(si_info, "total-count"),
            "ip_used": self._GET_INT(si_info, "used-count"),
            "ip_avail": self._GET_INT(si_info, "available-count"),
            "ip_ranges": self._GET_CONTENT_LIST(si_info, "ip-ranges")
        }

        return {'success': True, 'errmsg': '', 'data': dd}
コード例 #16
0
    def execute(self, server, cmd_data_json):
        # create the node details query first to see if valid
        qe_ndt = NaElement("node-details-info")
        qpcnt = 0
        if 'name' in cmd_data_json:
            qe_ndt.child_add_string("node", cmd_data_json['name'])
            qpcnt += 1
        if 'uuid' in cmd_data_json:
            qe_ndt.child_add_string("node-uuid", cmd_data_json['uuid'])
            qpcnt += 1

        if qpcnt < 1:
            return self._CREATE_FAIL_RESPONSE(
                'need at least one query parameter, got: ' +
                str(cmd_data_json))

        api = NaElement("system-node-get-iter")

        xi = NaElement("desired-attributes")
        xi1 = NaElement("node-details-info")
        xi1.child_add_string("node-uuid", "<node-uuid>")
        xi1.child_add_string("node", "<node>")
        xi1.child_add_string("node-serial-number", "<node-serial-number>")
        xi1.child_add_string("node-system-id", "<node-system-id>")
        xi1.child_add_string("product-version", "<product-version>")
        xi1.child_add_string("is-node-healthy", "<is-node-healthy>")
        xi1.child_add_string("node-uptime", "<node-uptime>")
        xi.child_add(xi1)
        api.child_add(xi)

        qe = NaElement("query")
        qe.child_add(qe_ndt)
        api.child_add(qe)

        resp, err_resp = self._INVOKE_CHECK(server, api,
                                            "system-node-get-iter")
        if err_resp:
            return err_resp

        node_cnt = self._GET_INT(resp, 'num-records')
        if node_cnt != 1:
            # too many nodes found for query
            return self._CREATE_FAIL_RESPONSE(
                'too many nodes found for query: [' + str(cmd_data_json) +
                '] result is: ' + resp.sprintf())

        if not resp.child_get("attributes-list"):
            return self._CREATE_FAIL_RESPONSE('no node data found in: ' +
                                              resp.sprintf())

        node_detail = resp.child_get("attributes-list").children_get()[0]
        uuid = self._GET_STRING(node_detail, "node-uuid")
        name = self._GET_STRING(node_detail, "node")
        serial = self._GET_STRING(node_detail, "node-serial-number")
        sysid = self._GET_STRING(node_detail, "node-system-id")
        version = self._GET_STRING(node_detail, "product-version")
        healthy = self._GET_BOOL(node_detail, "is-node-healthy")
        uptime = self._GET_INT(node_detail, "node-uptime")

        return {
            'success': True,
            'errmsg': '',
            'data': {
                "name": name,
                "serial": serial,
                "id": sysid,
                "uuid": uuid,
                "version": version,
                "healthy": healthy,
                "uptime": uptime
            }
        }
コード例 #17
0
    def execute(self, server, cmd_data_json):
        if ("name" not in cmd_data_json or "bc_domain" not in cmd_data_json):
            return self._CREATE_FAIL_RESPONSE(
                "subnet get commands must" +
                " have name and broadcast domain" + " defined, got: " +
                str(cmd_data_json))

        name = cmd_data_json["name"]
        bcdom = cmd_data_json["bc_domain"]
        cmd = "net-subnet-get-iter"

        call = NaElement(cmd)

        qe = NaElement("query")
        qi_si = NaElement("net-subnet-info")
        qi_si.child_add_string("broadcast-domain", bcdom)
        qi_si.child_add_string("subnet-name", name)
        qe.child_add(qi_si)

        call.child_add(qe)

        dattr = NaElement("desired-attributes")

        si = NaElement("net-subnet-info")

        si.child_add_string("subnet-name", "<subnet-name>")
        si.child_add_string("broadcast-domain", "<broadcast-domain>")
        si.child_add_string("ipspace", "<ipspace>")
        si.child_add_string("subnet", "<subnet>")
        si.child_add_string("gateway", "<gateway>")

        iprs = NaElement("ip-ranges")
        iprs.child_add_string("ip-range", "<ip-range>")
        si.child_add(iprs)

        si.child_add_string("total-count", "<total-count>")
        si.child_add_string("used-count", "<used-count>")
        si.child_add_string("available-count", "<available-count>")

        dattr.child_add(si)

        call.child_add(dattr)

        resp, err_resp = self._INVOKE_CHECK(server, call, cmd + ": " + name)
        if err_resp:
            return err_resp

        # LOGGER.debug(resp.sprintf())

        si_cnt = self._GET_INT(resp, 'num-records')
        if si_cnt != 1:
            # too many subnets found for query
            return self._CREATE_FAIL_RESPONSE('too many subnets found for' +
                                              ' query: [' +
                                              str(cmd_data_json) +
                                              '] result is: ' + resp.sprintf())

        if not resp.child_get("attributes-list"):
            return self._CREATE_FAIL_RESPONSE(
                'no subnet info data found in: ' + resp.sprintf())

        si_info = resp.child_get("attributes-list").children_get()[0]
        dd = {
            "bc_domain": self._GET_STRING(si_info, "broadcast-domain"),
            "gateway": self._GET_STRING(si_info, "gateway"),
            "ipspace": self._GET_STRING(si_info, "ipspace"),
            "subnet": self._GET_STRING(si_info, "subnet"),
            "name": self._GET_STRING(si_info, "subnet-name"),
            "ip_count": self._GET_INT(si_info, "total-count"),
            "ip_used": self._GET_INT(si_info, "used-count"),
            "ip_avail": self._GET_INT(si_info, "available-count"),
            "ip_ranges": self._GET_CONTENT_LIST(si_info, "ip-ranges")
        }

        return {'success': True, 'errmsg': '', 'data': dd}
コード例 #18
0
    def execute(self, server, cmd_data_json):
        if "name" not in cmd_data_json:
            return self._CREATE_FAIL_RESPONSE(
                "get broadcast domain commands must" +
                " have name defined, got: " + str(cmd_data_json))

        name = cmd_data_json["name"]
        cmd = "net-port-broadcast-domain-get-iter"

        call = NaElement(cmd)

        qe = NaElement("query")
        qe_bcdi = NaElement("net-port-broadcast-domain-info")
        qe_bcdi.child_add_string("broadcast-domain", name)
        qe.child_add(qe_bcdi)
        call.child_add(qe)

        dattr = NaElement("desired-attributes")
        bcdi = NaElement("net-port-broadcast-domain-info")
        bcdi.child_add_string("broadcast-domain", "<broadcast-domain>")
        bcdi.child_add_string("ipspace", "<ipspace>")
        bcdi.child_add_string("mtu", "<mtu>")
        bcdi.child_add_string("port-update-status-combined",
                              "<port-update-status-combined>")

        ports = NaElement("ports")
        pi = NaElement("port-info")
        pi.child_add_string("port", "<port>")
        pi.child_add_string("port-update-status", "<port-update-status>")
        pi.child_add_string("port-update-status-details",
                            "<port-update-status-details>")
        ports.child_add(pi)
        bcdi.child_add(ports)

        fog = NaElement("failover-groups")
        fog.child_add_string("failover-group", "<failover-group>")
        bcdi.child_add(fog)

        subs = NaElement("subnet-names")
        subs.child_add_string("subnet-name", "<subnet-name>")
        bcdi.child_add(subs)

        dattr.child_add(bcdi)

        call.child_add(dattr)

        resp, err_resp = self._INVOKE_CHECK(server, call, cmd + ": " + name)
        if err_resp:
            return err_resp

        # LOGGER.debug(resp.sprintf())

        bcd_cnt = self._GET_INT(resp, 'num-records')
        if bcd_cnt != 1:
            # too many bc domains found for query
            return self._CREATE_FAIL_RESPONSE(
                'too many broadcast domains found for' + ' query: [' +
                str(cmd_data_json) + '] result is: ' + resp.sprintf())

        if not resp.child_get("attributes-list"):
            return self._CREATE_FAIL_RESPONSE(
                'no broadcast domain info data found in: ' + resp.sprintf())

        bcd_info = resp.child_get("attributes-list").children_get()[0]

        dd = {
            "name":
            self._GET_STRING(bcd_info, "broadcast-domain"),
            "mtu":
            self._GET_STRING(bcd_info, "mtu"),
            "ipspace":
            self._GET_STRING(bcd_info, "ipspace"),
            "update_status":
            self._GET_STRING(bcd_info, "port-update-status-combined"),
            "ports": [],
            "failovergrps":
            self._GET_CONTENT_LIST(bcd_info, "failover-groups"),
            "subnets":
            self._GET_CONTENT_LIST(bcd_info, "subnet-names")
        }

        if bcd_info.child_get("ports"):
            # port info data available, process
            for port_info in bcd_info.child_get("ports").children_get():
                dd['ports'].append({
                    "name":
                    self._GET_STRING(port_info, "port"),
                    "update_status":
                    self._GET_STRING(port_info, "port-update-status"),
                    "status_detail":
                    self._GET_STRING(port_info, "port-update-status-details")
                })

        return {'success': True, 'errmsg': '', 'data': dd}
コード例 #19
0
    def execute(self, server, cmd_data_json):
        if not ("uuid" in cmd_data_json or "name" in cmd_data_json):
            return self._CREATE_FAIL_RESPONSE(
                'get IPSpace request must have uuid' + ' defined, got: ' +
                str(cmd_data_json))

        cmd = "net-ipspaces-get-iter"

        call = NaElement(cmd)

        qe = NaElement("query")
        qe_ii = NaElement("net-ipspaces-info")

        mark = "unknown"
        if "uuid" in cmd_data_json:
            mark = cmd_data_json["uuid"]
            qe_ii.child_add_string("uuid", mark)
        if "name" in cmd_data_json:
            mark = cmd_data_json["name"]
            qe_ii.child_add_string("ipspace", mark)

        qe.child_add(qe_ii)
        call.child_add(qe)

        des_attr = NaElement("desired-attributes")
        ii = NaElement("net-ipspaces-info")
        ii.child_add_string("ipspace", "<ipspace>")
        ii.child_add_string("uuid", "<uuid>")

        bcd = NaElement("broadcast-domains")
        bcd.child_add_string("broadcast-domain-name",
                             "<broadcast-domain-name>")
        ii.child_add(bcd)

        pts = NaElement("ports")
        pts.child_add_string("net-qualified-port-name",
                             "<net-qualified-port-name>")
        ii.child_add(pts)

        vser = NaElement("vservers")
        vser.child_add_string("vserver-name", "<vserver-name>")
        ii.child_add(vser)

        des_attr.child_add(ii)
        call.child_add(des_attr)

        resp, err_resp = self._INVOKE_CHECK(server, call, cmd + ": " + mark)
        if err_resp:
            return err_resp

        vlan_cnt = self._GET_INT(resp, 'num-records')
        if vlan_cnt != 1:
            # too many vlan's found for query
            return self._CREATE_FAIL_RESPONSE(
                'too many ipspaces found for query: [' + str(cmd_data_json) +
                '] result is: ' + resp.sprintf())

        if not resp.child_get("attributes-list"):
            return self._CREATE_FAIL_RESPONSE('no ipspace data found in: ' +
                                              resp.sprintf())

        ips_info = resp.child_get("attributes-list").children_get()[0]

        dd = {
            "name": self._GET_STRING(ips_info, "ipspace"),
            "uuid": self._GET_STRING(ips_info, "uuid"),
            "bc_domains": self._GET_CONTENT_LIST(ips_info,
                                                 "broadcast-domains"),
            "ports": self._GET_CONTENT_LIST(ips_info, "ports"),
            "vservers": self._GET_CONTENT_LIST(ips_info, "vservers")
        }

        return {'success': True, 'errmsg': '', 'data': dd}
コード例 #20
0
    def execute(self, server, cmd_data_json):
        if (
                "name" not in cmd_data_json and
                "uuid" not in cmd_data_json):
            return self._CREATE_FAIL_RESPONSE(
                'get SVM request must have name'
                + ' or uuid defined, got: '
                + str(cmd_data_json))

        cmd = "vserver-get-iter"
        call = NaElement(cmd)

        qe = NaElement("query")
        qe_vsi = NaElement("vserver-info")
        if "name" in cmd_data_json:
            qe_vsi.child_add_string(
                "vserver-name",
                cmd_data_json["name"])
        elif "uuid" in cmd_data_json:
            qe_vsi.child_add_string(
                "uuid", cmd_data_json["uuid"])
        qe.child_add(qe_vsi)
        call.child_add(qe)

        des_attr = NaElement("desired-attributes")
        vsi = NaElement("vserver-info")

        for prot_attr in ["allowed-protocols", "disallowed-protocols"]:
            alp = NaElement(prot_attr)
            alp.child_add_string("protocol","<protocol>")
            vsi.child_add(alp)

        vsi.child_add_string("ipspace","<ipspace>")
        vsi.child_add_string("is-config-locked-for-changes","<is-config-locked-for-changes>")
        vsi.child_add_string("operational-state","<operational-state>")
        vsi.child_add_string("operational-state-stopped-reason","<operational-state-stopped-reason>")
        vsi.child_add_string("root-volume","<root-volume>")
        vsi.child_add_string("root-volume-aggregate","<root-volume-aggregate>")
        vsi.child_add_string("root-volume-security-style","<root-volume-security-style>")
        vsi.child_add_string("state","<state>")
        vsi.child_add_string("uuid","<uuid>")
        vsi.child_add_string("volume-delete-retention-hours","<volume-delete-retention-hours>")
        vsi.child_add_string("vserver-name","<vserver-name>")

        des_attr.child_add(vsi)
        call.child_add(des_attr)

        resp, err_resp = self._INVOKE_CHECK(
            server, call, 
            cmd + ": " + str(cmd_data_json))
        if err_resp:
            return err_resp

        #LOGGER.debug(resp.sprintf())

        svm_cnt = self._GET_INT(resp, 'num-records')
        if svm_cnt != 1:
            # not exactly one svm received for query
            return self._CREATE_FAIL_RESPONSE(
                'not exactly one SVM received for: ['
                + str(cmd_data_json) + '] result is: '
                + resp.sprintf())

        if not resp.child_get("attributes-list"):
            return self._CREATE_FAIL_RESPONSE(
                'no svm data found in: '
                + resp.sprintf())

        svm_info = resp.child_get("attributes-list").children_get()[0]

        dd = {
            "name": self._GET_STRING(svm_info, "vserver-name"),
            "uuid": self._GET_STRING(svm_info, "uuid"),
            "ipspace": self._GET_STRING(svm_info, "ipspace"),
            "root_aggr": self._GET_STRING(svm_info, "root-volume-aggregate"),
            "root_sec_style": self._GET_STRING(svm_info, "root-volume-security-style"),
            "root_name": self._GET_STRING(svm_info, "root-volume"),
            "root_retent": self._GET_STRING(svm_info, "volume-delete-retention-hours"),
            
            "locked": self._GET_BOOL(svm_info, "is-config-locked-for-changes"),
            "svm_state": self._GET_STRING(svm_info, "state"),
            
            "proto_enabled": self._GET_CONTENT_LIST(svm_info, "allowed-protocols"),
            "proto_inactive": self._GET_CONTENT_LIST(svm_info, "disallowed-protocols")
        }

        dd["oper_state"] = self._GET_STRING(svm_info, "operational-state")
        if self._GET_STRING(svm_info, "operational-state-stopped-reason"):
            dd["oper_state"] += " caused by: " + self._GET_STRING(
                        svm_info, "operational-state-stopped-reason")

        return {
            'success' : True, 'errmsg': '', 'data': dd}